<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/star_icon"
android:id="+@starid"/>
I need to change tint color of icon programmatically help me
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/star_icon"
android:id="+@starid"/>
I need to change tint color of icon programmatically help me
Thanks for Hardik, orginal answer
You can change the tint, quite easily in code via:
imageView.setColorFilter(Color.argb(255, 255, 255, 255));
If you want color tint then:
imageView.setColorFilter(ContextCompat.getColor(context,
R.color.COLOR_YOUR_COLOR));
with mode:
imageView.setColorFilter(ContextCompat.getColor(context,
R.color.COLOR_YOUR_COLOR), android.graphics.PorterDuff.Mode.MULTIPLY);
in my case:
imgBottomDivider.setColorFilter(ContextCompat.getColor(getContext(),
mPreferences.isNightMode() ? R.color.colorWhite : R.color.colorBlack));
use
imageView.setColorFilter(int color, PorterDuff.Mode mode)
or
imageView.setColorFilter(int color)
Reference: https://developer.android.com/reference/android/widget/ImageView.html#setColorFilter(int)