Android JellyBean无法识别AttriubteSet的getTextSize

tar*_*oca 8 android attributes android-4.2-jelly-bean

我正在使用我在这里找到的类AutoResizeTextView:https: //stackoverflow.com/a/5535672/371778

这一直很有效,直到JellyBean.似乎JellyBean不识别textView AttributeSet中的getTextSize(),因为它返回0.0.

我尝试制作自定义xml属性,但我利用样式来使用AutoResizeTextView类,并且不能在styles.xml中包含自定义命名空间.

想知道如何让JellyBean识别这种方法吗?

小智 11

我遇到了同样的问题,我刚刚在AutoResizeTextView类中修复了它

 /**
 * 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();
}
Run Code Online (Sandbox Code Playgroud)

现在它适用于2.3,4.0和4.1.PF