我正在扩展 TextView 并加载自定义字体。我在列表视图中使用这个自定义文本视图。当我滚动列表时,有时会收到以下调试消息
布局期间 com.sample.CustomTextView{52afae4c V.ED.... ......ID 0,27-27,44 #7f060074 app:id/some_id} 不正确地调用 requestLayout():运行第二个布局过程
public class CustomTextView extends TextView {
private FontType mFontType;
public CustomTextView(Context context, AttributeSet attrs) {
super(context, attrs, 0);
if(!isInEditMode()){
TypedArray attributesArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CustomTextView, 0, 0);
try{
mFontType = FontType.values()[attributesArray.getInteger(R.styleable.CustomTextView_fontType, 0)];
setFontType(mFontType);
setTypeface(Cache.getCustomTypeface(mContext, LIGHT));
// Note: This flag is required for proper typeface rendering
setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}finally {
attributesArray.recycle();
}
}
}
}
但是,如果列表视图未滚动或首次加载时,则不会打印此警告。我需要覆盖某些内容并设置任何标志吗?
我不再收到此错误,这可能完全与使用 StickyHeaderListView 有关。我们删除了 StickyHeaderListView 并使用标准的 android ListView,一切似乎都工作正常。
如果您在日志中收到此警告。尝试删除自定义 ListView(如果有)并替换为标准 Android ListView,并验证这种情况不会发生。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)