huxq17 / XRefreshView

一个万能的android下拉上拉刷新的框架,完美支持recyclerview
1.7k stars 501 forks source link

XRefreshView与AppBarLayout滑动冲突, #112

Open icqapp opened 7 years ago

icqapp commented 7 years ago

当XRefreshView上拉使得AppBarLayout隐藏后,我设置AppBarLayout.addOnOffsetChangedListener(this);事件监听来设置XRefreshView的setPullRefreshEnable方法,但是不管用!!!XR还是不能下拉使得AppBarLayout显示出来 @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { Log.d("AppBarLayout:","位移:"+verticalOffset); xRefreshView.setPullRefreshEnable(verticalOffset == 0);//不能下拉 } xml代码如下

<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:icqapp="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent">

<!--第一部分:伸缩工具栏-->
<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        icqapp:contentScrim="?attr/colorPrimary"
        icqapp:expandedTitleMarginEnd="64dp"
        icqapp:expandedTitleMarginStart="48dp"
        icqapp:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/backdrop"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            android:src="@drawable/ic_toolbar_head"
            icqapp:layout_collapseMode="parallax" />

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    icqapp:layout_behavior="@string/appbar_scrolling_view_behavior">

    <com.andview.refreshview.XRefreshView
        android:id="@+id/xrefreshview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/rv_datas"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />
    </com.andview.refreshview.XRefreshView>

</LinearLayout>

</android.support.design.widget.CoordinatorLayout>

icqapp commented 7 years ago

已经解决!!! 可以这样改 @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { Log.d("AppBarLayout:","位移:"+verticalOffset); //xRefreshView.setPullRefreshEnable(verticalOffset == 0);//不能下拉 xRefreshView.setEnabled(verticalOffset == 0); }