在布局中包含工具栏后,主细节列消失

时间:2017-08-16 14:10:37

标签: android xml android-toolbar master-detail

在主详细信息布局中包含工具栏后,主列和详细列(以及垂直分隔符)由于某种原因已消失。需要做些什么来解决这个问题?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:divider="@drawable/divider_vertical"
    android:showDividers="middle"
    android:baselineAligned="false">

    <include layout="@layout/myToolbar"/>

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:id="@+id/master_container"/>

    <FrameLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="3"
        android:id="@+id/detail_container"/>

</LinearLayout>

enter image description here

1 个答案:

答案 0 :(得分:1)

试试这个:

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

    <include layout="@layout/myToolbar"/>

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:baselineAligned="false"
        android:divider="@drawable/divider_vertical"
        android:orientation="horizontal"
        android:showDividers="middle">

        <RelativeLayout
            android:id="@+id/master_container"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"/>

        <FrameLayout
            android:id="@+id/detail_container"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="3"/>

    </LinearLayout>

</LinearLayout>