![](/img/trans.png)
[英]SwipeRefreshLayout refreshes RecyclerView without having to pull down
[英]SwipeRefreshLayout - the RecyclerView is not pulled down
我有一個帶有GridLayoutManager
的RecyclerView
,使用SwipeRefreshLayout
, RecyclerView
未被下拉。 刷新時如何在工具欄和recyclerview之間產生間隙?
XML:
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RecyclerView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
碼:
swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_container);
swipeLayout.setOnRefreshListener(this);
swipeLayout.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light);
gridView = (RecyclerView) getActivity().findViewById(R.id.gridView);
gridLayoutManager = new GridLayoutManager(getActivity(), 4, GridLayoutManager.VERTICAL, false);
gridView.setLayoutManager(gridLayoutManager);
gridView.setVisibility(View.GONE);
gridView.setHasFixedSize(false);
gridView.setItemAnimator(new DefaultItemAnimator());
您的代碼還可以,但是swipeRefreshLayout不會下拉網格視圖,而只能下拉本身,對於演示,請查看此視頻 。 但是,您可以使用Ulta-Pull-to-Refresh之類的其他庫來實現所需的效果!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.