ビューの背景色を変更したいのですが、これが私が見つけた唯一の方法です。しかし、特定のAPIでのみ動作するというメッセージが表示されます。私はそれを何らかの形でAPI15まで動作させることはできますか?または、実際にボタンが選択されたことをユーザーに示すより良い方法はありますか?API 21の前にView.setBackgroundTintList?
選択したユーザーボタンのpublic static void setIconColor(TextView tv, int which, int color) {
tv.getCompoundDrawables()[which].mutate();
tv.getCompoundDrawables()[which].setColorFilter(ContextCompat.getColor(tv.getContext(), color), PorterDuff.Mode.SRC_ATOP);
}
public static void setIconColor(ImageView imageView, int color) {
imageView.getDrawable().mutate();
imageView.getDrawable().setColorFilter(ContextCompat.getColor(imageView.getContext(), color), PorterDuff.Mode.SRC_ATOP);
}
:
クリックは本当に醜いアニメーションを持っていますが、ありがとうございます。 – newToEverything