Android SwipeRefreshLayout 的用法

SwipeRefreshLayout嵌套reclerView 

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/home_swipe"
    android:layout_alignParentTop="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<com.salbacore.app.ui.view.home.MyLRecyclerView
    android:id="@+id/home_lrecyc"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

</android.support.v4.widget.SwipeRefreshLayout>

swipes.setColorSchemeResources(R.color.item9);
swipes.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
    @Override
    public void onRefresh() {

    }
});
// 设置子视图是否允许滚动到顶部 解决滑动冲突
swipes.setOnChildScrollUpCallback(new SwipeRefreshLayout.OnChildScrollUpCallback() {
    @Override
    public boolean canChildScrollUp(SwipeRefreshLayout parent, @Nullable View child) {
        return child.getScrollY() >0;
    }
});

猜你喜欢

转载自blog.csdn.net/qq_40446718/article/details/80910273