EditText not scrollable inside ScrollView

前端 未结 11 726
栀梦
栀梦 2020-12-02 12:36

I have a ScrollView inside which is an EditText which is set to scroll vertically. But it does not scrolls. Instead the whole layout scrolls, Whene

11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 12:56

    A simple way to do so is mentioned below with some description

                myEditText.setOnTouchListener(new View.OnTouchListener() {  //Register a callback to be invoked when a touch event is sent to this view.
                @Override
                public boolean onTouch(View v, MotionEvent event) {     
    //Called when a touch event is dispatched to a view. This allows listeners to get a chance to respond before the target view.
                    mScrollView.requestDisallowInterceptTouchEvent(true);
                    return false;
                }
            });
    

提交回复
热议问题