【发布时间】:2021-05-27 22:03:57
【问题描述】:
我在 SO 上查看了许多类似的问题,但没有任何帮助。
我有不同嵌套布局的层次结构,都有android:layout_width="fill_parent",最里面的布局有android:layout_width="wrap_content - 我需要将它对齐在中心(水平)。我该怎么做?
更新::我找到了问题的原因——如果我用android:layout_width="fill_parent" 将内部的LinearLayout 放入RelativeLayout,它仍然会包装它的内容。然而,TableRow 确实填满了屏幕。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TableRow >
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="1"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="2"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</TableRow>
</TableLayout>
</FrameLayout>
</LinearLayout>
【问题讨论】:
标签: android android-layout android-ui