我有RecyclerView
GridLayoutManager
,使用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>
CODE:
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());
答案 0 :(得分:2)
你的代码一切正常,但是swipeRefreshLayout不会拉下网格视图而只会拉下它自己,对于演示检查这个video。但是,您可以使用Ulta-Pull-to-Refresh之类的其他库来实现所需的效果!