如何在android xml visualizer的父垂直线性布局中包含子水平线性布局?

时间:2018-11-29 08:49:57

标签: android android-studio android-layout

在下面的子图像中,孩子的水平布局(黄色)仅覆盖屏幕的一半,另一半是栗色的(父垂直布局的颜色)。如何使水平布局覆盖整个第二半? / p>

image           >                      

2 个答案:

答案 0 :(得分:0)

这是您想要的吗?您的问题不清楚。 enter image description here

答案 1 :(得分:0)

这就是您想要的。

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:weightSum="2">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/background_dark"
        android:layout_weight="1">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@android:color/holo_orange_light"
            android:text="Demo Text" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:layout_weight="1"
        android:background="@color/red">

        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/desiredone"/>

    </LinearLayout>

</LinearLayout>