[英]How can I change the android button to dark grey instead of light grey
I would like to change the color of the android button in my application to be dark grey instead of light grey. 我想将应用程序中android按钮的颜色更改为深灰色而不是浅灰色。 I intent to keep the color of the focus/pressed the same. 我打算保持焦点/按下的颜色不变。 I just want to change the color of the button in 'normal' state to dark grey. 我只想将“正常”状态下的按钮颜色更改为深灰色。
I have found this thread: Standard Android Button with a different color 我发现了这个线程: 具有不同颜色的标准Android按钮
I think the easiest way is to do this. 我认为最简单的方法是这样做。 Is that correct? 那是对的吗? But how can I make the LightingColor Filter to make it darkgrey? 但是,如何使LightingColor滤镜使其变为深灰色?
button.getBackground().setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0xFFAA0000));
I have tried 我努力了
button.getBackground().setColorFilter(new LightingColorFilter(0xffffffff, 0xFF3A3A3A));
But all I get is a white color. 但是我得到的只是白色。
That's similar to what I am doing in my TabHost tabs in XML. 这类似于我在XML的TabHost选项卡中所做的事情。 If you have custom buttons and graphics it can be done in Java, but it is much easier if you're able to do it in your XML. 如果您具有自定义按钮和图形,则可以用Java来完成,但是如果能够以XML进行,则要容易得多。
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected, use grey -->
<item android:drawable="@drawable/settings"
android:state_selected="true" />
<!-- When not selected, use white-->
<item android:drawable="@drawable/mountain" />
</selector>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.