【发布时间】:2017-05-29 08:28:27
【问题描述】:
我将 3 个 TextView 放在 LinearLayout 中,并希望它们均匀分布并具有固定的高度。 layout_weight 和固定的layout_height 的组合应确保所有 3 个视图始终显示在一行中并且始终具有相同的高度。但他们不是。
谁能解释问题出在哪里?没找到……
这是我的LinearLayout 和它的孩子们:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvMuted"
android:text="@string/color_palette_muted"
android:foreground="?selectableItemBackground"
android:gravity="center"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_margin="4dp"
android:layout_height="64dp">
</TextView>
<TextView
android:id="@+id/tvMutedLight"
android:text="@string/color_palette_muted_light"
android:foreground="?selectableItemBackground"
android:gravity="center"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_margin="4dp"
android:layout_height="64dp">
</TextView>
<TextView
android:id="@+id/tvMutedDark"
android:text="@string/color_palette_muted_dark"
android:foreground="?selectableItemBackground"
android:gravity="center"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_margin="4dp"
android:layout_height="64dp">
</TextView>
</LinearLayout>
这就是我得到的:
【问题讨论】:
标签: android android-linearlayout android-xml