我有一個swipeRefresh裏面的回收器視圖每當我嘗試在頂部滾動滑動刷新方法被調用和佈局刷新,但我只想刷新佈局滾動到屏幕的頂部。有沒有人有這個問題的答案。如何刷新刷新佈局android
任何幫助表示讚賞,謝謝
我的佈局如下所示。
<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>
SwipeRefreshLayout
upload_swipe_refresh_layout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
webServiceCall();
upload_swipe_refresh_layout.setRefreshing(false);
}
});
的
爲什麼'RecyclerView'和'SwipeRefreshLayout'之間有'RelativeLayout'? 「SwipeRefreshLayout」不應該是「RecyclerView」的直接父代嗎?請參閱https://developer.android.com/training/swipe/add-swipe-interface.html – frozenkoi