(Android)ボタンなどの背景色を変える
簡単なことだけど、苦しんだのでメモ。
Android4.4と8.0で動作確認。
private void changeButtonColor(int id ,int color){ Button button = findViewById(id); Drawable drawable = button.getBackground(); drawable.setColorFilter(color,PorterDuff.Mode.SRC_IN); button.setBackground(drawable); }