Try this third-party library here. The height of the TextView will be fixed, but your text view size will be adjusted.
dependencies {
compile 'me.grantland:autofittextview:0.2.+'
}
Include any view that extends TextView in code:
AutofitHelper.create(textView);
Allow any view extending TextView in XML:
<me.grantland.widget.AutofitLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
/>
</me.grantland.widget.AutofitLayout>
XML:
<RootElement
xmlns:autofit="http://schemas.android.com/apk/res-auto"
...
<me.grantland.widget.AutofitTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:maxLines="2"
android:textSize="40sp"
autofit:minTextSize="16sp"
/>
. :
https://github.com/grantland/android-autofittextview