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) setTextSize(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
layoutName.addView(textViewName);
Thus you can use the resized TextView in your layout.