安卓layout_height 属性用于确定一个View 组件在特定单位中的高度。
你在布局文件中创建的所有视图组件都需要layout_height 这个属性。
要看一个关于layout_height 属性的例子,这里是一个有三个组件的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"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
android:text="Hello World!" />
<Button
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="Button" />
</LinearLayout>
LinearLayout 是容器,将layout_height 设置为match_parent 将使其高度与屏幕尺寸一致。
TextView 的layout_height 为200dp ,Button 的高度为100dp 。
设计视图将如下所示:

安卓布局_高度的尺寸说明
(android-layout-height.png)
与 layout_width属性一样,你可以为高度使用五个尺寸单位。dp,in,mm,pt,sp, 和px 。
dp 这个单位是最值得推荐的,因为它是一个与密度无关的像素,会根据你的屏幕密度相应地调整组件的大小。
有两个特殊的常数你可以用于高度:match_parent 和wrap_content 。
match_parent 常数将使用父组件的高度作为视图的高度。最外层的组件将使用屏幕的高度。
wrap_content 常数将根据内容的大小来调整高度。你的内容在垂直方向上越大,高度大小就越大。
这就是layout_height 属性的全部内容。👌