【发布时间】:2014-02-02 04:16:18
【问题描述】:
我使用 tableLayout,并且我想将 tableRow 的高度设置为尽可能高,以便正确显示 textViews(在 linearLayout 中)。目前,第二个 textView 没有正确显示(它根本不适合该行)。 这是 XML:
<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>
为了让我的问题更清楚,这就是图中的问题。第二个 textView 显示不正确:
【问题讨论】:
-
为表格行尝试 android:layout_height = "wrap_content"
-
@saopayne 没有帮助。
-
尝试 android:layout_weight = "2" 并给每个 textview 的 layout_weight 1
-
@saopayne 有点用,但现在第二个文本视图与第一个重叠(但不是全部,只是一点点)。
-
使用标准复选框首选项并保持与 Android 操作系统一致可能更容易
标签: android xml android-layout