make main content area active in DrawerLayout

后端 未结 2 967
情书的邮戳
情书的邮戳 2020-12-06 08:22

How to make active main content area, while drawer is open. Currently, if main content area is clicked, drawer will be closed then touch event will be dropped, I want to cat

2条回答
  •  时光说笑
    2020-12-06 08:56

    I solved my problem with temporarily solution, not so elegant, but does the job for a while, maybe contains side effects. I always return false in onInterceptTouchEvent() call and everything is active everytime.

    public class CustomDrawerLayout extends DrawerLayout {
    
        public CustomDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
    
        public CustomDrawerLayout(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public CustomDrawerLayout(Context context) {
            super(context);
        }
    
        @Override
        public boolean onInterceptTouchEvent(MotionEvent ev) {
            // always false and event will be send to each view
            return false;
        }   
    }
    

提交回复
热议问题