难道setShadowLayer()上的一个按钮的工作?按钮、工作、setShadowLayer

2023-09-04 02:55:26 作者:我和闺蜜一起祸害天下

我想改变一个按钮上的文本的阴影,我无法得到它的工作。

I'm trying to change the drop shadow of the text in a button and I can't get it working.

我想改变基于所述按钮的状态的颜色。我试图用一个颜色选择阴影颜色,但它崩溃的应用程序。它似乎并不想用一个选择该属性。所以,现在我想用在运行时做

I want to change the color based on the state of the button. I tried using a color selector for the shadow color but it crashed the app. It didn't seem to want to use a selector for that attribute. So, now I am trying to do it at run time using

button.setShadowLayer(1, 1, 1, android.R.color.black);

但是,它根本不进行任何更改。

However, it doesn't change anything at all.

我怎样才能得到这个工作?

How can I get this to work?

谢谢了

推荐答案

此方法用于更改包含的按钮(也内的文本的影子,你应该低音android.R.color.black直接,它的ID黑色,而不是本身的颜色,请参阅参考资料类的更多信息。)

This method is used to change the shadow on the text contained inside the button (also, you should bass android.R.color.black directly, it's the ID of the black color, not the color itself, see the Resources class for more info.)