【发布时间】:2014-06-04 22:24:12
【问题描述】:
这就是我的 LinearLayout(水平)行的样子:
我希望复选框的文本位于一行;按钮不必那么宽 - 它们仍然有足够的空间,复选框文本加长了一点。我的 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>
...需要更改以强制我的复选框文本不换行吗?
更新
按照 Der Golem 的建议,添加以下内容:
android:lines="1"
...并且还将复选框的 layout_weight 从 1 更改为 2(按钮设置为 1)给了我我想要的:
【问题讨论】:
标签: android-layout android-linearlayout android-button android-checkbox