Android: Make multiline edittext scrollable, disable in vertical scroll view

后端 未结 3 640
春和景丽
春和景丽 2021-01-06 15:41

I am developing an application in which i am struct at a point.

As according to my application requirement i created horizontal scrollview in xml and then vertical s

3条回答
  •  无人及你
    2021-01-06 15:59

    EditText editText = findViewById(R.id.editText);
    editText.setOnTouchListener(new OnTouchListener() {
                   public boolean onTouch(View view, MotionEvent event) {
                        // TODO Auto-generated method stub
                        if (view.getId() ==R.id.common_remark) {
                            view.getParent().requestDisallowInterceptTouchEvent(true);
                            switch (event.getAction()&MotionEvent.ACTION_MASK){
                            case MotionEvent.ACTION_UP:
                                view.getParent().requestDisallowInterceptTouchEvent(false);
                                break;
                            }
                        }
                        return false;
                    }
            });
    

    And in xml add this line in EditText:

    android:scrollbars = "vertical"
    

提交回复
热议问题