8

I am utilizing a class AutoResizeTextView I found here: https://stackoverflow.com/a/5535672/371778

This has worked great until JellyBean. It would seem that JellyBean doesn't recognize getTextSize() from the textView AttributeSet for it returns 0.0.

I tried making a custom xml attributes, but I utilize styles to use the AutoResizeTextView class and cannot include a custom namespace within styles.xml.

Any idea of a work around to get JellyBean to recognize this method?

Community
  • 1
  • 1
taraloca
  • 8,731
  • 9
  • 40
  • 74

3 Answers3

11

I have had the same problem and I just solved it with a fix in the AutoResizeTextView class

 /**
 * When text changes, set the force resize flag to true and reset the text size.
 */
@Override
protected void onTextChanged(final CharSequence text, final int start, final int before, final int after)
{
    mNeedsResize = true;
    mTextSize = getTextSize(); // I ADDED THIS
    // Since this view may be reused, it is good to reset the text size
    resetTextSize();
}

Now it works on 2.3, 4.0 and 4.1 the same. p.f.

Pavel P.F.
  • 171
  • 1
  • 3
  • reducing MIN_TEXT_SIZE to 10 worked for me. // Minimum text size for this text view public static final float MIN_TEXT_SIZE = 10; – lakhan_Ideavate Feb 26 '16 at 12:19
4

Above code works, but problems occur when AutoResizeTextView will be reused. For example in the ListView. After scaling one entry on the list some entries below could be also unnecessarily smaller. In this case onTextChanged method should look like:

@Override
protected void onTextChanged(final CharSequence text, final int start, final int before, final int after)
{
    needsResize = true;
    if (before == after)
        textSize = getTextSize();
    else
        resetTextSize(); // Since this view may be reused, it is good to reset the text size    
}
kolczak
  • 151
  • 7
0

I had seen an issue regarding Streaming. On a streaming video when I had tried to go fwd and bwd, I had seen a restart.

Bharath Gupta
  • 324
  • 3
  • 7
  • 20