Android UI布局,可以显示4个不同大小的ListFragment,就像显示一个很长的ListFragment一样

Android UI布局,可以显示4个不同大小的ListFragment,就像显示一个很长的ListFragment一样,android,android-layout,android-listfragment,Android,Android Layout,Android Listfragment,主布局中有4个ListFragment,如下代码所示。我应该应用什么布局或属性来保证所有4个ListFragment的所有元素都将按顺序显示,无论每个ListFragment可能有多长 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pa

主布局中有4个ListFragment,如下代码所示。我应该应用什么布局或属性来保证所有4个
ListFragment
的所有元素都将按顺序显示,无论每个
ListFragment
可能有多长

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <fragment
        android:id="@+id/todolist_newitem"
        android:name="com.example.tek.first.servant.todolist.fragment.NewItemAddedFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true" />

    <fragment
        android:id="@+id/todolist_displayfragment_incomplete_items"
        android:name="com.example.tek.first.servant.todolist.fragment.display.IncompleteDetailedItemsDisplayFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/todolist_newitem" />

    <fragment
        android:id="@+id/todolist_displayfragment_simple_todoitems"
        android:name="com.example.tek.first.servant.todolist.fragment.display.SimpleToDoItemsDisplayFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/todolist_displayfragment_incomplete_items" />

    <fragment
        android:id="@+id/todolist_displayfragment_completed_items"
        android:name="com.example.tek.first.servant.todolist.fragment.display.CompletedDetailedItemsDisplayFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/todolist_displayfragment_simple_todoitems" />

</RelativeLayout>

我尝试了
LinearLayout
RelativeLayout
ScrollView
,将
layout\u height
作为
wrap\u content
match\u parent

如果第一个
列表片段
太长(超过屏幕高度),在
线性布局
相对布局
情况下,它将“隐藏”/“覆盖”其余三个;如果第一个
ListFragment
几乎与屏幕一样长,例如它占据了屏幕的2/3,那么剩余的三个
ListFragment
只能滚动显示在屏幕的最后1/3部分,第二个可能“覆盖”第三个,等等
对于
ScrollView
,每个
ListFragment
只有一行项目,因此整个屏幕中只有4行项目,每个项目都可以为其
ListFragment
滚动
上述情况都不符合我的要求。我想要的是按照片段和片段中元素的顺序直接显示所有
ListFragment
,就像只显示一个非常长的
ListFragment
一样。我该怎么办?

我知道
TabLayout
是最小的选择,或者将
ArrayList
中的所有4个
ListFragment
数据合并为一个。但还能做些什么呢?有更好的解决方案吗?

相对
更改为
线性布局
(垂直),使用
layout\u height=“match\u parent”
然后在片段集
layout\u weight=“1”
layout\u height=“0dp”
。“权重”的工作原理类似于%,这意味着它为一个视图组中的所有视图提供相同的高度(因为值为1)。
谢谢

你的设备屏幕会神奇地变大吗?可能不是这样不你不能保证它总是显示列表中的每一项你可能最好使用一个ListView并在ListView/适配器中创建部分。使用多行类型很容易,所以我从这里开始。