我有一个XML格式的形状:如何动态改变形状颜色?
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:topLeftRadius="8dip"
android:topRightRadius="8dip"
android:bottomLeftRadius="8dip"
android:bottomRightRadius="8dip"/>
</shape>
我想这个形状是一个按钮的形状。但当我声明:
button.setBackgroundDrawable(the shape)
我不能以后改变按钮的颜色。它总是给我黑色背景,我想动态地改变颜色。 我试过了:
button.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
它没有任何影响。 谢谢。
对不起,但这些都不起作用... – LiorZ 2012-07-30 05:23:12
发布您的完整代码 – saravana 2012-08-01 09:20:51