Pages Navigation Menu

Coding is much easier than you think

Auto Scale TextView Text to Fit within Bounds

Auto Scale TextView Text to Fit within Bounds

1. You can create a Class to check for the TextView size

2. Edit the text view size to the maximum size allotted.

public FitView(Context context, AttributeSet attrs) {

super(context, attrs);

float size = this.getTextSize();

if (size > MAX_TEXT_SIZE)




3. Then create an object for the Class in your activity. The constructor will be called automatically and resizing will be done.

This resized TextView will be stored in the object created textViewName.


FitView textViewName = new FitView(context, attrs);

4. Then add it to a view by


Thus you can use the resized TextView in your layout.

About Gokul

I am very much interested in android and Wicket framework. A core android developer and working in android native app development and responsive web mobile design. I have also worked in wicket fame work and java web development. I will keep on updating you about android and wicket framework and answer your query.

%d bloggers like this: