📜  如何使 textview 在滚动视图内可滚动 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:14.048000             🧑  作者: Mango

代码示例1
/**
 * If this [AppCompatTextView] is placed inside ScrollView then we allow it get scrolled inside
 * that ScrollView
 */
fun AppCompatTextView.makeScrollableInsideScrollView() {
    movementMethod = ScrollingMovementMethod()
    setOnTouchListener { v, event ->
        v.parent.requestDisallowInterceptTouchEvent(true)
        when (event.action and MotionEvent.ACTION_MASK) {
            MotionEvent.ACTION_UP -> {
                v.parent.requestDisallowInterceptTouchEvent(false)
                //It is required to call performClick() in onTouch event.
                performClick()
            }
        }
        false
    }