8

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

这在 JellyBean 之前一直很有效。JellyBean 似乎无法从 textView AttributeSet 中识别 getTextSize(),因为它返回 0.0。

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

有什么想法可以让 JellyBean 识别这种方法吗?

4

3 回答 3

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();
}

现在它同样适用于 2.3、4.0 和 4.1。pf

于 2012-07-19T09:33:05.680 回答
4

上面的代码有效,但是当 AutoResizeTextView 将被重用时会出现问题。例如在 ListView 中。缩放列表中的一个条目后,下面的一些条目也可能不必要地变小。在这种情况下,onTextChanged 方法应如下所示:

@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    
}
于 2012-10-24T10:26:07.873 回答
0

我看到了一个关于流媒体的问题。在我尝试使用 fwd 和 bwd 的流媒体视频中,我看到了重新启动。

于 2012-08-30T08:49:48.617 回答