在禁用的 ImageButton 上拖放

Drag and Drop on Disabled ImageButton

当我将某些东西拖放到图像按钮上时,我希望它改变颜色。 使用此代码启用按钮时效果很好:

DragEvent.ACTION_DRAG_DROP -> {
   it.background.mutate().setColorFilter(ContextCompat.getColor(mContext, R.color.entered_zone), PorterDuff.Mode.SRC_IN)
   return@OnDragListener true
}

但是,如果我这样做: endorsedBtn.isEnabled = false

那么按钮不会改变颜色。 为什么会这样,有什么我可以做的吗?

来自documentation

Note that this step only occurs if the user drops the drag shadow within the bounding box of a View whose listener is registered to receive drag events. If the user releases the drag shadow in any other situation, no ACTION_DROP drag event is sent.

禁用图像按钮也会禁用它的侦听器。

您可以创建一个自定义按钮并决定您自己的内部禁用功能。

更多信息here