如何改变实习Android Android绘图的颜色?

use*_*332 3 java icons android colors drawable

我试图将Android的实习图标(anrdoid.R.drawable.bla)放入ImageButton,我想改变Icon的颜色(不是背景!),但它不能像我想的那样工作.

这是我尝试过的:

来自布局的我的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" />
Run Code Online (Sandbox Code Playgroud)

我在我的活动中尝试过的内容:

Drawable myIcon = getResources().getDrawable( android.R.drawable.ic_lock_silent_mode); 
    ColorFilter filter = new LightingColorFilter( R.color.blue, R.color.blue);
    myIcon.setColorFilter(filter);
Run Code Online (Sandbox Code Playgroud)

无论我为LightingColorFilter尝试了什么值,它总能给出相同的结果.Imagebutton中的图标变暗.但这不是我所说的.我只是想从colors.xml中应用一种颜色,它在某种程度上无法解决.

这是否是正确的方向我要去?或者是否存在另一种机会(我并不是说在Photoshop中将自己着色并将它们放入drawables文件夹中)

Mar*_*vic 7

这对我有用,例如它会涂成深灰色:

ImageButton imgBtn = (ImageButton) findViewById(R.id.imageButton11); // image button
            imgBtn.setColorFilter(getResources().getColor(android.R.color.darker_gray), Mode.SRC_ATOP);
Run Code Online (Sandbox Code Playgroud)