How to scroll the edittext inside the scrollview

前端 未结 12 1997
南笙
南笙 2020-12-02 10:27

I have a scrollview inside which there is a editext which is multiline. I want to scroll the edittext to see the lower content but it can\'t be done.

12条回答
  •  孤城傲影
    2020-12-02 11:10

    Use this code it's working

    In XML

    android:singleLine="false"
    android:overScrollMode="always"
    android:scrollbarStyle="insideInset"
    android:scrollbars="vertical"
    

    In programming

    edittext.setOnTouchListener(new View.OnTouchListener() {
    
        public boolean onTouch(View view, MotionEvent event) {
    
            if (view.getId() == R.id.edittext) {
                view.getParent().requestDisallowInterceptTouchEvent(true);
                switch (event.getAction() & MotionEvent.ACTION_MASK) {
                case MotionEvent.ACTION_UP:
                    view.getParent().requestDisallowInterceptTouchEvent(false);
                    break;
                }
            }
            return false;
        }
    });
    

提交回复
热议问题