Android layout: running second layout pass
Asked Answered
L

1

6

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() 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 ?

Lucinalucinda answered 27/2, 2014 at 19:53 Comment(0)
L
2

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.

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.

Lucinalucinda answered 14/7, 2014 at 19:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.