Skip to content Skip to sidebar Skip to footer

Wrap Text In Button Gracefully At Whitespace

I have an android application in which a user can create what is basically a macro and label that macro with some text. I then create a button for them with their descriptive text.

Solution 1:

you can add this attribute to your Button's XML that will magically put the whole text in one line:

android:singleLine="true"

or you can verify the text before you insert it to the button and check the number of words.. if it is too long like more than 25 characters then break it on the second or third whitespace then set it to the button.

hope I got your question right.

Solution 2:

AFAIK there's no simple way to do precisely what you want. You can get a decent look using android:singleLine="true" and android:ellipsize="marquee". Also, since you have already implemented your own Button class, take a peek at this question

Solution 3:

I had a button which said "Off" and had a drawable to the left, but it was wrapping to two lines. i.e.

Image O
      ff

The solution was that I removed the drawablePadding style. i.e.

<itemname="android:drawablePadding">5dp</item>

Post a Comment for "Wrap Text In Button Gracefully At Whitespace"