Is there a way to have a TextView pick a font size such that it fills whatever space it has available? For example:
<LinearLayout
layout_width="fill_parent"
layout_height="50dip" >
<TextView
layout_width="fill_parent"
layout_height="fill_parent"
textSize="scale?" />
</LinearLayout>
Thanks
No, there is not built in font scaling in a TextView
. You could overload the onDraw()
method in a child of TextView
, but TextView
does not support scaling the text automatically.
Take a look at this other question.
Just to update, from API 26 (Android 8.0) TextViews has an attribute to scale text on horizontal and vertical axes
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
android:autoSizeTextType="uniform" />
Check it at Autosizing TextViews
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With