【发布时间】:2019-07-04 01:03:30
【问题描述】:
布局
<ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false">
<ConstraintLayout
android:layout_width="24dp"
android:layout_height="24dp"
android:translationX="5dp"
android:translationY="5dp"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toStartOf="parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@android:color/black"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</ConstraintLayout>
</ConstraintLayout>
我想为imageView处理点击事件,所以我设置了简单的监听器来点击它。
imageView.setOnClickListener {
Log.d("ClickEvent", "imageView Clicked")
}
我只能在触摸橙色区域时收到点击事件。但我也想在触摸 红色 区域时收到点击事件。
注意red是裁剪区域,orange是非裁剪区域(red+orange = imageView area),gray是ConstraintLayout。
即使用户触摸剪切区域,是否有任何方法可以接收点击事件? (如果可以的话,可以通过code或者xml来实现吗?)
【问题讨论】:
-
同样的问题,不幸的是我并没有真正找到解决方案
标签: android android-layout android-view