【发布时间】:2016-12-18 07:41:47
【问题描述】:
这是我创建的 XML 文件。我无法设置LinearLayout 的高度。我已将LinearLayout 的方向设置为水平,并使用layout_weight 设置LinearLayout 的高度。
但是,当我将 TextView 的高度设置为 match_parent 时,它不起作用。
<RelativeLayout 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"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
tools:context=".MainActivity"
android:weightSum="3">
<LinearLayout
android:id="@+id/a"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="1"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="2"/>
</LinearLayout>
<LinearLayout
android:id="@+id/b"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_below="@id/a">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="3"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="4"/>
</LinearLayout>
<LinearLayout
android:id="@+id/c"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal"
android:layout_below="@id/b">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="5"/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="6"/>
</LinearLayout>
</RelativeLayout>
【问题讨论】:
-
“不工作”和“不工作”是什么意思?
标签: android android-layout android-view android-xml