ListView in BottomSheet

前端 未结 8 2363
梦毁少年i
梦毁少年i 2020-12-13 07:39

I ran into a problem where I had a simple ListView in a BottomSheet and ListView had enough items to fill the screen and scroll even m

8条回答
  •  长情又很酷
    2020-12-13 07:49

    There is a better approach if you don't want to extend the ListView:

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

提交回复
热议问题