更改子布局使AppBarLayout $ ScrollingViewBehavior错误

时间:2018-03-05 03:41:33

标签: android android-coordinatorlayout android-appbarlayout

这是我的布局:

CoordinatorLayout AppBarLayout ... AnimatableTabs SwipeRefreshLayout

现在没有问题。

现在,Down Gesture的行为是:

1.首先扩展AppBarLayout。

2.show pullDownRefresh SwipeRefreshLayout第二圈。

enter image description here

但是,我为AnimatableTabs添加了一个动画。

```科特林 appbar.addOnOffsetChangedListener {appBarLayout,verticalOffset - >     ...

// FIXME: 2018/3/5
//This code make behavior incorrectly.
ll_tabs.apply {
    ll_tabs_left.apply widthProvider@ {
        layoutParams = (layoutParams as LinearLayout.LayoutParams).apply {
            leftMargin = (this@widthProvider.width * collapsedHotPercent).toInt()
        }
    }
    ll_tabs_right.apply widthProvider@ {
        layoutParams = (layoutParams as LinearLayout.LayoutParams).apply {
            rightMargin = (this@widthProvider.width * collapsedHotPercent).toInt()
        }
    }

    //It seems requestLayout() make behavior incorrectly.
}

}

发生了一个问题:

Down Besture的行为是:

展开AppBarLayout并同时显示pullDownRefresh Circle。

enter image description here

这是代码:

code on GitHub

无论如何要修复它?似乎requestLayout()使行为不正确。

1 个答案:

答案 0 :(得分:0)

解决。通过改变xml结构:

CoordinatorLayout AppBarLayout ... Tabs AnimatableElements SwipeRefreshLayout

现在我可以使用自定义行为。