-1
私は質問があります。 はなぜDrawableCompat.setTint()メソッドのウォーキングが正しくないのはなぜですか?
Drawable drawable = getResources().getDrawable(R.drawable.some_drawable);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable.mutate(), getResources().getColor(R.color.white));
を使用するときに動作していない、と私は
Drawable drawable = getResources().getDrawable(R.drawable.some_drawable);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable.mutate(), R.color.white);
を使用するときに働いていますか?ドキュメントで
が
public static void setTint(@NonNull Drawable drawable, @ColorInt int tint){}
のようなものですので、私はリソースではなく、int型を提供する必要があるということです。
ありがとうございます。
編集:私は色のリソースを提供する場合、私の関数は@ColorInt
で注釈されている場合
私が見る、(..., @ColorInt int color)
は、働いています。もっと混乱しています。そうでない場合、リソースの色は無視されます。
'tint:\tこのドロアブルを着色するための色ですので、リソースIDではなく32ビット長のintカラーが必要です – pskink
Btw' @ ColorInt'はカラー値ですが '@ ColorRes'はリソースIDです。 – StuStirling