我有一个简单的自定义 TextView,它在其构造函数中设置自定义字体,如下面的代码
public class MyTextView extends TextView {
@Inject CustomTypeface customTypeface;
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
RoboGuice.injectMembers(context, this);
setTypeface(customTypeface.getTypeface(context, attrs));
setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
}
}
从 Gingerbread 到 JB 4.2 都可以正常工作。但是,当我在 Android 4.3 手机上显示我的自定义文本视图时,adb logcat 中充斥着以下消息。
10-05 16:09:15.225: WARN/View(9864): requestLayout() improperly called by com.cmp.views.MyTextView{42441b00 V.ED.... ......ID 18,218-456,270 #7f060085 app:id/summary} during layout: running second layout pass
10-05 16:09:15.225: WARN/View(9864): requestLayout() improperly called by com.cmp.views.MyTextView{423753d0 V.ED.... ......ID 26,176-742,278 #7f060085 app:id/summary} during layout: running second layout pass
我注意到,它确实会减慢 UI 的速度。有什么想法为什么会在 4.3 上发生?
感谢你的帮助。