How can I force my checkbox's text to not wrap?
Posted
by
B. Clay Shannon
on Stack Overflow
See other posts from Stack Overflow
or by B. Clay Shannon
Published on 2014-06-04T22:24:12Z
Indexed on
2014/06/05
15:25 UTC
Read the original article
Hit count: 406
This is what my LinearLayout (horizontal) row looks like:
I want the text of the checkbox to be on one line; The buttons don't have to be that wide - they'll still have plenty of space with the checkbox text lengthened a bit. What in my 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>
...needs to change in order to force my checkbox text not to wrap?
UPDATE
Following Der Golem's suggestion by adding this:
android:lines="1"
...and also changing layout_weight for the checkbox from 1 to 2 (set to 1 for the buttons) gave me what I wanted:
© Stack Overflow or respective owner