自定义背景的Andr​​oid禁用按钮 [英] disable button with custom background android

查看:101
本文介绍了自定义背景的Andr​​oid禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我有一个Android按钮,将其设置为禁用,则该按钮,似乎是透明的。

When I have an android button and set it as disabled then the button seems as "transparent".

我有一个自定义的背景pssed的$ P $按钮和聚焦状态。我想从code禁用它。当我尝试 button.setEnabled(假); 我关闭按钮,但它保持相同的自定义背景。任何想法如何禁用我的自定义按钮,更改背景为透明的吗?

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?

推荐答案

也许你可以使用安卓state_enabled ,并设置到适当的透明绘制在你选择这个按钮?

Maybe you could use android:state_enabled and set that to appropriate transparent drawable in your selector for this button?

这篇关于自定义背景的Andr​​oid禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆