Search code examples
androidandroid-coordinatorlayoutandroid-appbarlayout

Change child layout make AppBarLayout$ScrollingViewBehavior incorrectly


Here is my layout:

CoordinatorLayout AppBarLayout ... AnimatableTabs SwipeRefreshLayout

And there is no problem now.

Now The Behavior of Down Gesture is:

1.Expand AppBarLayout first.

2.show pullDownRefresh Circle of SwipeRefreshLayout second.

enter image description here

But,after I add a animate for AnimatableTabs.

```kotlin 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.
}

}

There is a problem happened:

The Behavior of Down Gesture is:

Expand AppBarLayout and show pullDownRefresh Circle at the same time.

enter image description here

And here is code:

code on GitHub

Anyway to fix it?It seems requestLayout() make behavior incorrectly.


Solution

  • Solved. by changed xml structure:

    CoordinatorLayout AppBarLayout ... Tabs AnimatableElements SwipeRefreshLayout

    And now I can use custom behavior.