在可展开列表视图之后向视图添加线性布局,而不会在填充时被可展开列表视图覆盖



发生的情况是,当我填充列表视图时,可扩展列表视图下方的线性布局将消失。我希望"@+id/bottomActionBarAppointments"布局始终在屏幕上可见。我不想为可扩展列表视图设置静态高度。提前感谢任何帮助。
以下是我的布局 xml:

<LinearLayout 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"
    android:orientation="vertical"
    tools:context=".AppointmentsActivity" >
    <LinearLayout
        android:id="@+id/calendar1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
    </LinearLayout>
    <ExpandableListView
        android:id="@+id/expandableListViewAppointments"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:groupIndicator="@null" >
    </ExpandableListView>
    <LinearLayout
        android:id="@+id/bottomActionBarAppointments"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
    </LinearLayout>
</LinearLayout>

在尝试了一些更改后找到了答案。我使用layout_weight属性来允许每个线性布局共享屏幕的特定部分。以下是我的布局 XML:

<LinearLayout 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"
    android:orientation="vertical"
    tools:context=".AppointmentsActivity" >
    <LinearLayout
        android:id="@+id/calendar1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@color/green"
        android:layout_weight="0.1" >
    </LinearLayout>
    <LinearLayout
        android:id="@+id/listViewLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0.8">
        <ExpandableListView
            android:id="@+id/expandableListViewAppointments"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:groupIndicator="@null" >
        </ExpandableListView>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/bottomActionBarAppointments"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@color/green" 
        android:layout_weight="0.1">
    </LinearLayout>
</LinearLayout>

最新更新