SeekBar in a NavigationDrawer

前端 未结 2 791
花落未央
花落未央 2021-02-18 18:34

I want to use a seekbar in a Navigation Drawer

Basically I need to slide left and right to set the seekbar and, well, you guessed it, it slides the navigation drawer...<

2条回答
  •  再見小時候
    2021-02-18 19:02

    Just add an onTouchListener. When you touch the screen on the seekbar (action_down) disallow parent to intercept the event.

    seekbar.setOnTouchListener(new ListView.OnTouchListener() 
    {
        @Override
        public boolean onTouch(View v, MotionEvent event) 
        {
            int action = event.getAction();
            switch (action) 
            {
            case MotionEvent.ACTION_DOWN:
                // Disallow Drawer to intercept touch events.
                v.getParent().requestDisallowInterceptTouchEvent(true);
                break;
    
            case MotionEvent.ACTION_UP:
                // Allow Drawer to intercept touch events.
                v.getParent().requestDisallowInterceptTouchEvent(false);
                break;
            }
    
            // Handle seekbar touch events.
            v.onTouchEvent(event);
            return true;
        }
    });
    

提交回复
热议问题