
我希望复选框的文本在一行;按钮不必那么宽 – 它们仍然有足够的空间,复选框文本延长了一点.在我的XML中:
<linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:orIEntation="horizontal"> <CheckBox androID:ID="@+ID/ckbxAllow_New_Items" androID:layout_wIDth="0dip" androID:layout_height="fill_parent" androID:layout_weight="1" androID:checked="true" androID:text="@string/checkBox_Allow_New_Items" /> <button androID:ID="@+ID/btnOK" androID:layout_wIDth="0dip" androID:layout_height="wrap_content" androID:layout_weight="1" androID:text="@string/button_OK" /> <button androID:ID="@+ID/btnCancel" androID:layout_wIDth="0dip" androID:layout_height="wrap_content" androID:layout_weight="1" androID:text="@string/button_Cancel" /></linearLayout>
…需要更改以强制我的复选框文本不要换行?
UPDATE
遵循Der Golem的建议添加:
androID:lines="1"
…并且还将复选框的layout_weight从1更改为2(按钮设置为1)给了我想要的内容:
解决方法 CheckBox继承自Compoundbutton,后者继承自button,后者继承自TextVIEw.所以,它具有这些祖先的所有属性,方法和属性……参考: http://developer.android.com/reference/android/widget/CheckBox.html
特别是,您对TextVIEw属性,方法和属性感兴趣:
参考:http://developer.android.com/reference/android/widget/TextView.html
特别是,您对androID:lines属性感兴趣,并将其设置为1.
这告诉您的CheckBox正好是1行高.
您可能还想将androID:ellipsize属性设置为某个值(即:3 = end).
这告诉你的CheckBox在截断文本的结尾,开始,中心等处添加三个点(省略号).
[编辑]
作为TextVIEw的一个优势,它可以使用setSingleline – 感谢@CrandellWS的评论.
总结以上是内存溢出为你收集整理的android-layout – 如何强制我的复选框文本不包装?全部内容,希望文章能够帮你解决android-layout – 如何强制我的复选框文本不包装?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)