//xml
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/spinner"
app:layout_constraintStart_toEndOf="@id/msg2"
app:layout_constraintTop_toTopOf="@+id/msg2"
app:layout_constraintEnd_toEndOf="parent"
android:entries="@array/week"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
//.kt
@SuppressLint("ClickableViewAccessibility")
private val mOnTouchListener = View.OnTouchListener { view, event ->
return@OnTouchListener true // true:禁止点击事件的传递
}
//最后,给spinner添加禁用点击事件方法
binding?.spinner?.setOnTouchListener(mOnTouchListener)
效果: