Search code examples
androidattributesandroid-4.2-jelly-bean

Android JellyBean not Recognizing getTextSize of AttriubteSet


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?


Solution

  • 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.