'auto adjust text size to fit a button Android

Is there a way to auto adjust the text size of a button to be the biggest it can be while stayinh one line, and still fit in the button?



Solution 1:[1]

Have a look at Autosizing TextViews (provides support to API level 14).

For example

<Button
    android:id="@+id/button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:maxLines="1"
    android:text="Some text"
    app:autoSizeTextType="uniform" />

The key property here is app:autoSizeTextType

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vasily Kabunov