【发布时间】:2011-09-03 05:39:27
【问题描述】:
请看上面的截图,文本的字符串是“DELETE SELECTED\nMESSAGES”,如果我使用 wrap_content 作为其父线性布局的宽度/高度,文本将如下所示:
删除
选择
消息
(每个单词之间没有行间距)
如果我使用 match-parent 作为按钮的宽度,它将被拉伸以匹配其父级,这不是我想要的。谁能帮我解决这个问题?
谢谢!
编辑:
按钮的布局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_margin="5dip"
android:paddingTop="5dip"
android:paddingBottom="0dip"
android:background="@drawable/solid_grey_btm_rounded">
<Button
android:text="@string/delete_selected_messages"
android:id="@+id/btn_delete_message"
android:gravity="center"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="@drawable/button_grey_selector">
</Button>
</LinearLayout>
我正在使用 Android 2.3.3 API Level 10,我正在摩托罗拉里程碑(带有真正键盘的那个)上进行测试
【问题讨论】:
-
它对我有用。如果您说您使用的是哪个Android版本以及什么手机,也许会有所帮助
-
也许你可以使用固定宽度..你可以发送你的布局代码吗?
标签: android layout text button alignment