1

In Android where can I set the text that automatically reduce size when is too long ?

Using android:autoText="true" doesn't work.

David
  • 34,355
  • 30
  • 113
  • 139
paul75
  • 47
  • 2
  • 8

4 Answers4

3

Add app:autoSizeTextType="uniform" to your Button. Check this link for more details.

Mateus Gondim
  • 4,226
  • 4
  • 26
  • 48
0

Try to use:

android:ellipsize="end"

It will add 3 dots at the end of the text if it's too long.

David
  • 34,355
  • 30
  • 113
  • 139
  • 1
    this is terrible when translating an app to a foreign language because foreign languages typically have words which are much longer than in english. Hence, pretty much all textview's would end up with ... Google needs to address this IMO – Someone Somewhere Apr 03 '16 at 16:30
0

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>
Fahim
  • 11,496
  • 4
  • 36
  • 56
0

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.

Community
  • 1
  • 1
Rajen Raiyarela
  • 5,050
  • 4
  • 18
  • 39