Android 如何扩展kotlin中片段的查看范围?

Android 如何扩展kotlin中片段的查看范围?,android,android-studio,android-fragments,Android,Android Studio,Android Fragments,下面的代码运行的视图范围很小。目前,它只在片段的最顶端运行 以下是setOnTouchListener的代码: val view = inflater.inflate(R.layout.fragment_main, container, false) view.setOnTouchListener(View.OnTouchListener { view, motionEvent -> if (motionEvent.action == MotionEvent.ACT

下面的代码运行的视图范围很小。目前,它只在片段的最顶端运行

以下是setOnTouchListener的代码:

val view = inflater.inflate(R.layout.fragment_main, container, false)
view.setOnTouchListener(View.OnTouchListener { view, motionEvent ->
            if (motionEvent.action == MotionEvent.ACTION_UP){
                texteffectskip = true
            }
            return@OnTouchListener true
        })
activity_main.xml

<FrameLayout
        android:id="@+id/main_frame"
        android:layout_width="match_parent"
        android:layout_height="0dp"

当前,视图有ScrollView和ReyclView。
我想如果我按下ScrollView,View就会被按下。
但事实并非如此。
因此,我必须将TouchListener附加到另一个视图

var scroller = view.findViewById(R.id.scroll_content) as ScrollView
scroller.setOnTouchListener(View.OnTouchListener { view, motionEvent ->
    if (motionEvent.action == MotionEvent.ACTION_UP){
        texteffectskip = true
    }
    return@OnTouchListener true
})
var scroller = view.findViewById(R.id.scroll_content) as ScrollView
scroller.setOnTouchListener(View.OnTouchListener { view, motionEvent ->
    if (motionEvent.action == MotionEvent.ACTION_UP){
        texteffectskip = true
    }
    return@OnTouchListener true
})