Android的按钮的背景颜色 [英] Android button background color
问题描述
我想设置一个按钮的背景颜色在我的应用程序,我无法实现我想要的结果......
I am trying to set the background color of a button in my app and I am unable to achieve the result that I want...
这是我想设置的颜色是 holo_green_light(#ff99cc00)
。为了做到这一点,我使用 setColorFilter(0xff99cc00,PorterDuff.Mode.MULTIPLY);
The color that I am trying to set is holo_green_light(#ff99cc00)
. In order to do it, I am using setColorFilter(0xff99cc00, PorterDuff.Mode.MULTIPLY);
这是我得到的颜色不是 holo_green_light
,但浅灰的搭配和 holo_green_light
。
The color that I get is not the holo_green_light
but a mix of lightgrey and holo_green_light
.
我已经尝试使用了 LightingColorFilter
没有成功。
I have tried using the LightingColorFilter
without much success.
有没有办法做到这一点编程,使按钮看起来像一个按钮,而不是一个平面矩形,我需要的颜色。
Is there a way to do it programatically, so that the button appears like a button and not a flat rectangle with the color that I need.
推荐答案
按钮是更复杂的不仅仅是改变一个颜色......
Buttons are more complex than just changing one color...
Android的按键使用相当多的9补丁和状态可绘制成。你应该看看的Android河洛颜色来生成这些,你会希望选择彩色按钮,它会生成必要图片及XML为你...
Android buttons are made using quite a few 9-patches and state drawables. You should take a look at Android Holo Colors to generate those, you would want to select "Color Button" and it will generate the necessary images & xml for you...
这篇关于Android的按钮的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!