How to scroll the edittext inside the scrollview

前端 未结 12 1998
南笙
南笙 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 10:53

    Thanks to Hariharan, vovahost I got the same solution, but added performClick() to avoid a warning.

    EditText (XML):

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

    Code:

    edit_text.setOnTouchListener { view, event ->
        view.parent.requestDisallowInterceptTouchEvent(true)
        if ((event.action and MotionEvent.ACTION_MASK) == MotionEvent.ACTION_SCROLL) {
            view.parent.requestDisallowInterceptTouchEvent(false)
        } else {
            performClick()
        }
        return@setOnTouchListener false
    }
    

提交回复
热议问题