Android的布局:在运行第二布局传递 [英] Android layout: running second layout pass
问题描述
我TextView的扩展和加载自定义的字体。我使用列表视图这个自定义文本视图。当我有时滚动列表我得到以下调试消息
I'm extending TextView and loading a custom typeface. I'm using this custom text view in a list view. When I scroll the list sometimes I get the following debug messages
requestLayout()由com.sample.CustomTextView不当称为{52afae4c V.ED .... ...... ID 0,27-27,44#7f060074应用:ID / SOME_ID}布局中:运行第二布局传递
requestLayout() improperly called by com.sample.CustomTextView{52afae4c V.ED.... ......ID 0,27-27,44 #7f060074 app:id/some_id} during layout: running second layout pass
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();
}
}
}
}
但这种警告是不是如果列表视图不滚动或打印时其加载的第一次。我需要的东西覆盖,并设置任何标志?
However this warning is not printed if the list view is not scrolling or when its loaded first time. Do i need to override something and set any flags ?
推荐答案
我再也不会收到此错误,这可能是完全与所用StickyHeaderListView做。我们删除了StickyHeaderListView并用标准的Android ListView和一切似乎是工作的罚款。
I don't get this error anymore and this could have been totally to do with StickyHeaderListView being used. We removed the StickyHeaderListView and used standard android ListView and everything seems to be working fine.
如果你正在在日志中这样的警告。尝试,如果任何删除自定义的ListView和标准Android的ListView更换并确认不会发生这种情况。
If you are getting this warning in logs. Try removing custom ListView if any and replace with standard Android ListView and verify that this does not happen.
这篇关于Android的布局:在运行第二布局传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!