【发布时间】:2013-05-07 20:40:12
【问题描述】:
<LinearLayout 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:orientation="horizontal"
android:weightSum="6"
tools:context=".MainActivity" >
<Button
android:text="BTN1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_weight="1" />
<Button
android:text="BTN2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_weight="2" />
<Button
android:text="BTN3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_weight="1" />
<Button
android:text="BTN4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_weight="1" />
<Button
android:text="BTN5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="fill_vertical"
android:layout_weight="1" />
</LinearLayout>
使用android:layout_height="match_parent" 只是将按钮拉伸到整个屏幕高度。我希望按钮 2 的宽度是其他按钮的两倍。
【问题讨论】:
-
减小文本大小 android:textSize="10dp"。减小所有按钮的文本大小
-
@Raghunandan 这不是一个可接受的解决方案。我想保持一切原样,文本大小、颜色、重量、按钮的顺序,只是按钮 2,在这种情况下,我希望它与同一行上其他按钮的高度相匹配
-
那么它认为不可能。好吧,我很好奇,期待更好的解决方案
-
@Raghunandan 查看已接受的答案 + 我的评论
-
@Raghunandan 这就是这个问题的重点,我不希望文本在同一行。我希望按钮的高度相同,无论它们显示多少行文本。
标签: android android-layout button height