我有以下布局:
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="200dp"
app:layout_behavior="com.github.an.CustomBehaviour">
//Other views
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rvList"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
在CustomBehaviour
内部onNestedScroll(...)
如果第一个RecyclerView
的元素已滚动50%(或部分),我想做一些事情:
public class CustomBehaviour extends CoordinatorLayout.Behavior<AppBarLayout> {
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, final AppBarLayout appbar, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
if(first element scrolled partially) {
do something
}
}
}
有可能实现这个目标吗?