如何在Android中动态改变图像的色彩? [英] How to Change image color dynamically in android?
本文介绍了如何在Android中动态改变图像的色彩?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在做这种类型的项目,在我的项目变化图片色彩动态
I am doing such type of project ,In my project change Image color dynamically.
我有一个黑色形状的彩色图像,当用户在这个图像变化图像颜色动态绿色的点击。的
谷歌搜索和其他文件遵循,但我没有解决我的问题。
Googling and other document follow but I am not solve my problem .
请帮帮我,有什么方法或文档遵循解决我的问题,
Please help me , is there any method or document to follow solve my problem ,
推荐答案
下面是我如何做到这一点:它是从资源的XML文件拉动颜色
Here's how I do this: It's pulling the color from a resource xml file.
<resources>
<color name="new_color">#FFAAAAAA</color>
</resources>
在你的活动.java文件:
In your activity .java file:
import android.graphics.PorterDuff.Mode;
Resources res = context.getResources();
final ImageView image = (ImageView) findViewById(R.id.imageId);
final int newColor = res.getColor(R.color.new_color);
image.setColorFilter(newColor, Mode.SRC_ATOP);
要清除它称之为:
image.setColorFilter(null);
这篇关于如何在Android中动态改变图像的色彩?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文