Androidのインターンアイコン(anrdoid.R.drawable.bla)をImageButtonに入れようとしましたが、アイコンの色(背景ではありません!)を変更したかったのですが、思い通りに動作しません。
これが私が試したことです:
レイアウトからの私のImageButton:
<ImageButton
android:id="@+id/imageButton1"
android:layout_marginTop="100dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/background"
android:src="@android:drawable/ic_lock_silent_mode" />
アクティビティで試したこと:
Drawable myIcon = getResources().getDrawable( android.R.drawable.ic_lock_silent_mode);
ColorFilter filter = new LightingColorFilter( R.color.blue, R.color.blue);
myIcon.setColorFilter(filter);
LightingColorFilter で試した値に関係なく、常に同じ結果が得られます。Imagebutton 内のアイコンが暗くなります。しかし、それは私が望んだことではありません。私は自分のcolors.xmlから色を適用したかったのですが、どうにかうまくいきません。
これは正しい方向ですか?または、別の操作がありますか (Photoshop で自分自身に色を付けて、drawables フォルダーに入れるという意味ではありません)