繁体   English   中英

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

[英]How to change the color of intern Android drawables?

我试图将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" />

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

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文件夹中)

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM