简体   繁体   English

带有GridLayoutManager的RecyclerView并将布局堆栈倒向底部

[英]RecyclerView with GridLayoutManager and reverse layout stack to bottom

I am using a RecyclerView with a GridLayoutManager . 我正在将RecyclerViewGridLayoutManager一起使用。 On that layout manager, I call setReverseLayout(true) so the elements are displayed in reverse order. 在该布局管理器上,我调用setReverseLayout(true)以便以相反的顺序显示元素。

But now, the RecyclerView is initially displayed from the end of the list. 但是现在, RecyclerView最初是从列表的末尾显示的。 I know there is a setStackFromEnd(boolean) method, but it is not compatible with GridLayoutManager . 我知道有一个setStackFromEnd(boolean)方法,但是它与GridLayoutManager不兼容。

What is the best way to display the elements in reverse order and still having the RecyclerView being displayed from the top? 逆序显示元素并从顶部开始显示RecyclerView的最佳方法是什么?

Here is my layout file using the RecyclerView : 这是我使用RecyclerView布局文件:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.mgaetan89.showsrage.fragment.ShowsSectionFragment">

    <android.support.v7.widget.RecyclerView
        android:id="@android:id/list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="@dimen/grid_margin"
        android:clipToPadding="false"
        android:paddingBottom="@dimen/fab_spacing"/>

    <TextView
        android:id="@android:id/empty"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="@string/no_shows"
        android:visibility="gone"/>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/add_show"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end|right"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/ic_add_black_24dp"/>
</FrameLayout>

I tired got to find solution with recycler view so finally I used GridView 我累了要用回收者视图找到解决方案,所以最后我使用了GridView

<GridView
    android:id="@+id/lv_explore"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="5dp"
    android:dividerHeight="0dip"
    android:horizontalSpacing="5dp"
    android:numColumns="3"
    android:scrollbars="none"
    android:verticalSpacing="5dp"
    android:stackFromBottom="true" />

and used this property android:stackFromBottom="true" 并使用了此属性android:stackFromBottom="true"

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

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