问题描述
当我有一个 android 按钮并将其设置为禁用时,按钮看起来是透明的".
When I have an android button and set it as disabled then the button seems as "transparent".
我有一个带有自定义背景的按钮,用于按下和聚焦状态.我想从代码中禁用它.当我尝试 button.setEnabled(false);
我禁用按钮但它保持相同的自定义背景.知道如何禁用我的自定义按钮并将背景更改为透明吗?
I have a button with custom background for the pressed and focused state. I want to disable it from code. When I try button.setEnabled(false);
I disable the button but it keeps the same custom background. Any idea how to disable my custom button and changes the background as transparent too?
推荐答案
也许您可以使用 android:state_enabled
并将其设置为该按钮的选择器中适当的透明可绘制对象?
Maybe you could use android:state_enabled
and set that to appropriate transparent drawable in your selector for this button?
这篇关于禁用具有自定义背景android的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!