Reputation: 47
In Android where can I set the text that automatically reduce size when is too long ?
Using android:autoText="true"
doesn't work.
Upvotes: 1
Views: 4143
Reputation: 5532
Add app:autoSizeTextType="uniform"
to your Button. Check this link for more details.
Upvotes: 5
Reputation: 5636
From android developer page it says This class accesses a dictionary of corrections to frequent misspellings, as well as this page it says If set, specifies that this TextView has a textual input method and automatically corrects some common spelling errors. The default is "false".
Must be a boolean value, either "true" or "false".
This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.
This corresponds to the global attribute resource symbol autoText., so android:autoText="true"
is not for adjusting the text size but it is something related to spell correction.
From what i understand about your problem, you are looking for a solution through which text is fully displayed on button and never truncated. If text is longer than button size, textsize should be reduced to fit in the text within the button bounds.
So there is one post related to autosize but it is related to Textview. So you can use this as starting point and build your solution.
Upvotes: 0
Reputation: 12358
use android:ellipsize="end" property when the text is longer than the size of the button
<Button android:text="Button"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:ellipsize="end">
</Button>
Upvotes: 0
Reputation: 37536
Try to use:
android:ellipsize="end"
It will add 3 dots at the end of the text if it's too long.
Upvotes: 0