【问题标题】:SwipeRefreshLayout - the RecyclerView is not pulled downSwipeRefreshLayout - RecyclerView 没有被下拉
【发布时间】:2015-04-22 17:50:09
【问题描述】:

我有一个RecyclerViewGridLayoutManager,当使用SwipeRefreshLayout 时,RecyclerView 没有被拉下。 toolbarrecyclerview 刷新时如何创建有间隙的效果?

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

【问题讨论】:

  • 你试过什么?可能是粘贴你的 xml 布局代码?
  • 我发布了代码,但它是这两个视图的最简单实现。我认为问题出在 GridLayoutManager,但我不确定
  • 不,因为我的甚至没有向下移动。刷新工作,刷新视图显示,但在网格顶部,网格没有移动。
  • 尝试在线性垂直布局中添加它

标签: java android android-recyclerview


【解决方案1】:

您的代码一切正常,但是 swipeRefreshLayout 不会拉下网格视图,而只会拉下它自己,对于演示,请检查此 video。但是,您可以使用 Ulta-Pull-to-Refresh 等其他库来达到预期的效果!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-30
    • 1970-01-01
    • 2015-10-31
    • 1970-01-01
    • 2017-08-08
    • 1970-01-01
    • 2017-01-02
    • 1970-01-01
    相关资源
    最近更新 更多