I am wondering how can I create or use if exists feature of TextView, to automatically change it's font size to fit the place.
Sometimes it should be larger if has space, and sometimes it should shrink in font size to fit the space.
What do you say?
app:autoSizeMinTextSize=”10sp” using this attribute the TextView will be resized up to the size of 10sp and app:autoSizeStepGranularity=”2sp” using this attribute we are uniformly reducing the size of the TextView as 2sp when it goes out of the screen.
SetText(String, TextView+BufferType) Sets the text to be displayed using a string resource identifier.
autoSizeMaxTextSize is the maximum size of textview it will take autoSizeMinTextSize is the minimum size of textview it will take and autoSizeStepGranularity is the size of each step.
you can change the font in your overrided version of
protected void onSizeChanged (int w, int h, int oldw, int oldh)
method.You need just to subclass TextView to do it.
Also, check this.
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