简体   繁体   English

SwipeRefreshLayout-未将RecyclerView下拉

[英]SwipeRefreshLayout - the RecyclerView is not pulled down

I have a RecyclerView with GridLayoutManager and when using SwipeRefreshLayout the RecyclerView is not pulled down. 我有一个带有GridLayoutManagerRecyclerView ,使用SwipeRefreshLayoutRecyclerView未被下拉。 How to create the effect of having a gap between the toolbar and the recyclerview while refreshing? 刷新时如何在工具栏recyclerview之间产生间隙?

XML: 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());

Your code is all okay, but the swipeRefreshLayout does not pull down the grid view but only itself, For the demo check this video . 您的代码还可以,但是swipeRefreshLayout不会下拉网格视图,而只能下拉本身,对于演示,请查看此视频 You can however use other libraries like Ulta-Pull-to-Refresh to achieve the desired effect! 但是,您可以使用Ulta-Pull-to-Refresh之类的其他库来实现所需的效果!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM