Android 安卓系统中的多分区卡布局设计?

Android 安卓系统中的多分区卡布局设计?,android,android-layout,android-recyclerview,Android,Android Layout,Android Recyclerview,下图是谷歌I/O 2015应用程序的第一页 我想实现这样的目标。每张卡片中的每个部分都有一些详细信息,如RecyclerView以及右上角的More按钮 我试过这样的方法 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/root">

下图是谷歌I/O 2015应用程序的第一页

我想实现这样的目标。每张卡片中的每个部分都有一些详细信息,如
RecyclerView
以及右上角的
More
按钮

我试过这样的方法

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:id="@+id/root">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Updates"/>

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical"
        android:id="@+id/updates">
    </android.support.v7.widget.RecyclerView>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Videos"/>

    <android.support.v7.widget.RecyclerView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="vertical"
        android:id="@+id/videos">
    </android.support.v7.widget.RecyclerView>

</LinearLayout>


但是,我不确定这是否是正确的方法。我们是否需要为每个部分使用每个
RecyclerView
?假设,如果我有5个部分,那么我应该有5个
RecyclerView

是的,你可以为每个部分使用一个
RecyclerView
。但是,我认为这需要很多内存

此外,对于每个部分,请将其放入如下的
卡片视图中:

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="360dp"
    android:layout_height="300dp"
    android:layout_marginStart="12dp"
    android:foreground="?android:attr/selectableItemBackground"
    card_view:cardCornerRadius="4dp"
    card_view:cardElevation="2dp">

    <RelativeLayout
        android:id="@+id/root"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Updates"
            android:id="@+id/textView" />

        <android.support.v7.widget.RecyclerView
            android:id="@+id/updates"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="vertical"
            android:layout_below="@+id/textView" />

    </RelativeLayout>
</android.support.v7.widget.CardView>


您不应使用多个RecyclerViews。您可以将所需的设计按节归档到RecyclerView。有许多方法可以将节添加到RecyclerView。如果你是新手,那么使用一些库项目,比如是的,他是对的,就像我说的,这将占用大量内存,所有用户都无法使用它。@Sharj我看过那个库。我有多个带有自定义对象的数组列表,并保存从web服务获取的更新、视频、文章数据。如何为具有多个
arrayList
的适配器设置单个
recyclerView
?@LinX64您什么都没说。但是,‘为什么像我说的那样?’我在回答中说了!等待更好的解决方案。你应该避免出现多次滚动的情况。@Sharj-是的,好吧,这是一个很好的观点。我认为最好的选择是像你所说的那样使用库,但是,让我们看看是否有其他人有更好的主意。谢谢你提到它,我没有想到:)