Runtime DrawerLayout must be measured with MeasureSpec.EXACTLY excpetion

后端 未结 2 2102
庸人自扰
庸人自扰 2020-12-19 05:09

I\'m following this tutorial from and I\'m facing with a strange problem.

It doesn\'t matter what\'s in my DrawerLayout, but if its layout_height

相关标签:
2条回答
  • 2020-12-19 05:38

    Try overriding the DrawerLayout's on measure method

    public class CustomDrawerLayout extends DrawerLayout {
    
    public CustomDrawerLayout(Context context) {
        super(context);
    }
    
    public CustomDrawerLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
    public CustomDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
    
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        widthMeasureSpec = MeasureSpec.makeMeasureSpec(
                MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY);
        heightMeasureSpec = MeasureSpec.makeMeasureSpec(
                MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.EXACTLY);
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }
    
    }
    
    0 讨论(0)
  • 2020-12-19 05:50

    I found putting requestWindowFeature(Window.FEATURE_NO_TITLE); before setContent() could solve this in my case.

    0 讨论(0)
提交回复
热议问题