Skip to content Skip to sidebar Skip to footer

How Can I Force My Checkbox's Text To Not Wrap?

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

Solution 1:

CheckBox inherits from CompoundButton, which inherits from Button, which inherits from TextView. So, it has all the properties, methods and attributes of these ancestors... Reference: http://developer.android.com/reference/android/widget/CheckBox.html

In particular, you are interested to the TextView properties, methods and attributes: Reference: http://developer.android.com/reference/android/widget/TextView.html

In particular, you're interested in the android:lines attribute, and set it to 1. This tells your CheckBox to be exactly 1 line tall.

You might also want to set the android:ellipsize attribute to some value (i.e.: 3 = end). This tells your CheckBox to add three dots (ellipsis) to the end, start, center, ... of the truncated text.

[EDIT]

Being a decentant of TextView, it can use setSingleLine - Thanks to @CrandellWS for the comment.

Post a Comment for "How Can I Force My Checkbox's Text To Not Wrap?"