Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何设置要相互分割的子视图的宽度?_Android - Fatal编程技术网

Android 如何设置要相互分割的子视图的宽度?

Android 如何设置要相互分割的子视图的宽度?,android,Android,我正在尝试创建一个线性布局,左视图宽度为其父视图宽度的80%,第二个视图占用剩余空间。我如何做到这一点 在定义子视图时尝试使用android:layout\u weight 对于视图1,使用0.8的布局权重;对于视图2,使用0.2的布局权重 示例xml是: android:layout_weight=".8" 像这样: 不要忘记将宽度设置为0 看看这里:这是关于同样的问题 <TextView android:layout_width="0dp" android:l

我正在尝试创建一个线性布局,左视图宽度为其父视图宽度的80%,第二个视图占用剩余空间。我如何做到这一点


在定义子视图时尝试使用android:layout\u weight

对于视图1,使用0.8的布局权重;对于视图2,使用0.2的布局权重

示例xml是:

android:layout_weight=".8"
像这样:

不要忘记将宽度设置为0


看看这里:这是关于同样的问题
<TextView
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight=".8"
    android:background="@color/blue" />

<TextView
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_weight=".2"
    android:background="@color/red" />