I am doing such type of project ,In my project change Image color dynamically.
I have a one black shape color image ,when user click on this image change image color dynamically green.
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 ,
Tint color means when we want to change the color of the image while rendering in ImageView. In XML is very easy to change tint color by just setting up the attribute android:tint="" in the ImageView tag, as shown in the following example.
Here's how I do this: It's pulling the color from a resource xml file.
<resources> <color name="new_color">#FFAAAAAA</color> </resources>
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);
To clear it call:
image.setColorFilter(null);
Set android:tint attribute of image/image button to the color you need.
android:tint="@android:color/black"
Optionally you can set android:tintMode attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With