disable an ImageButton?

前端 未结 5 780
旧时难觅i
旧时难觅i 2020-12-10 10:29

I wanted to leave an ImageButton is disabled (not clickable) but have used android: enabled = \"false\" and does\'t work.

5条回答
  •  悲&欢浪女
    2020-12-10 10:49

    If you want to disable and "grey out" the image, I use the following (Kotlin):

    Disable:

    chevron_left.imageAlpha = 75 // 0 being transparent and 255 being opaque
    chevron_left.isEnabled = false
    

    Enable:

    chevron_left.imageAlpha = 255
    chevron_left.isEnabled = true
    

    XML:

    
    

    Note that the your background color will define the color of the disabled state. Depends on your desired result.

提交回复
热议问题