私は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);
影響はありません。ありがとう。