ScrollView fighting with scroll of TimePicker, Timepicker not scrolling as a result

后端 未结 1 1198
情话喂你
情话喂你 2021-01-02 10:48

Hopefully there is a solution here, I have a XML TimePicker and ScrollView in my main.xml and with the set up the TimePicker does not scroll. If I remove the ScrollView the

相关标签:
1条回答
  • 2021-01-02 11:15

    Found the solution, create a custom TimePicker class and then call this to override touch events:

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        // Stop ScrollView from getting involved once you interact with the View
        if (ev.getActionMasked() == MotionEvent.ACTION_DOWN) {
            ViewParent p = getParent();
            if (p != null)
                p.requestDisallowInterceptTouchEvent(true);
        }
        return false;
    }
    
    0 讨论(0)
提交回复
热议问题