Android 如何根据最高列设置高度?
我使用tableLayout,并希望将tableRow的高度设置为必须的高度,以便正确显示文本视图(位于linearLayout中)。目前,第二个textView没有正确显示(它根本不适合该行)。 这是XML:Android 如何根据最高列设置高度?,android,xml,android-layout,Android,Xml,Android Layout,我使用tableLayout,并希望将tableRow的高度设置为必须的高度,以便正确显示文本视图(位于linearLayout中)。目前,第二个textView没有正确显示(它根本不适合该行)。 这是XML: <TableLayout android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/background">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/stripe_background"
android:gravity="right|center_vertical"
android:paddingTop="@dimen/stripe_padding_buttons_top_bottom"
android:paddingBottom="@dimen/stripe_padding_buttons_top_bottom"
android:paddingLeft="@dimen/stripe_padding_sides"
android:paddingRight="@dimen/stripe_padding_sides"
android:layout_marginBottom="@dimen/stripe_margin_top_bottom">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_column="0"
android:layout_weight="1"
android:paddingRight="@dimen/stripe_padding_between_text_views"
android:gravity="right|center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_text_view_current_consumption_main"
android:id="@+id/textViewCurrentConsumptionMain"
android:textColor="@color/big_text"
android:textSize="@dimen/small_text"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_text_view_current_consumption_additional"
android:id="@+id/textViewCurrentConsumptionAdditional"
android:textColor="@color/small_text"/>
</LinearLayout>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/checkBox"
android:layout_column="1"
android:button="@drawable/check_box_custom"
android:checked="true" />
</TableRow>
</TableLayout>
为了让我的问题更清楚,这是图片中的问题。第二个文本视图未正确显示:
制作
LinearLayout
和所有TextView
s高度到wrap\u content
(TableRow
)也可以使用android:layout\u height=“wrap\u content”查看表格row@saopayne没有帮助。请尝试android:layout\u weight=“2”,并为每个文本视图设置一个布局权重1@saopayne这种方法奏效了,但现在第二个文本视图与第一个文本视图重叠(但不是全部,只是一点点)。使用标准复选框首选项并保持与Android操作系统一致可能会更容易