Android 基于设备屏幕宽度/高度指定布局中视图的相对尺寸

Android 基于设备屏幕宽度/高度指定布局中视图的相对尺寸,android,layout,Android,Layout,我正在编写一个android应用程序,它有3个视图一个视图比另一个视图低 根据屏幕大小,每个视图的高度必须相等 每个视图占据整个屏幕的宽度 如何在布局xml中指定视图必须占据设备显示高度的1/3高度 在这种情况下,合适的布局是什么?试试android:layout\u weight=“1” 试试android:layout\u weight=“1” 这是如何指定要平均分配的高度的?从android文档:在LinearLayout部分下查找重量说明。为每个子视图指定android:layo

我正在编写一个android应用程序,它有3个
视图
一个视图比另一个视图低

根据屏幕大小,每个视图的高度必须相等

每个视图占据整个屏幕的宽度

如何在布局xml中指定视图必须占据设备显示高度的1/3高度


在这种情况下,合适的
布局是什么?

试试android:layout\u weight=“1”



试试android:layout\u weight=“1”



这是如何指定要平均分配的高度的?从android文档:在LinearLayout部分下查找重量说明。为每个子视图指定android:layout_weight=“1”将引导布局平均分配高度。请参阅Scott指出的文档。这是如何指定要平均分布的高度的?从android文档:在LinearLayout部分下查找重量说明。为每个子视图指定android:layout_weight=“1”将引导布局平均分布高度。请参阅Scott指出的文件。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<View  
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1"
    android:background="#F00"
    />
<View  
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1"
    android:background="#0F0"
    />
<View  
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1"
    android:background="#00F"
    />