每次我尝试在顶部滚动时,都会调用滑动刷新方法并刷新布局,但我只想在滚动到屏幕顶部时刷新布局。这个问题有人能回答吗?
感谢任何帮助,谢谢
我的布局如下所示。
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:id="@+id/rel"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:scrollbars="vertical" />
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
最佳答案
我解决了我的问题。我必须重新排列我的代码才能使其正常工作。 现在,lyout 在到达屏幕顶部时刷新。
<RelativeLayout
android:id="@+id/rel"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/toolbar">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/swipe_container"
android:scrollbars="vertical" />
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
关于android - 如何在滑动刷新android中刷新布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38389365/