Good community, my problem is this:
I'm inflating images with the Glide library because putting the image path directly in the xml
makes my app go slower.
In the xml
I have the following code for an image:
<ImageView
android:id="@+id/img_principal_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
android:scaleType="centerCrop"
android:tint="@color/colorPrimaryLight"
android:tintMode="screen" />
And in code the following glide code:
Glide.with(this).load(R.drawable.mijares_cascada).into(imgPrincipal);
The problem is that the code of tint
does not apply even though it is set to xml
, that is, this code that causes the image to have a different color tone:
android: tint="@ color / colorPrimaryLight"
android: tintMode="screen"
EXTENSION
I have also tried to do it from code after inflating the image with the glide in this way but it does not work either:
Glide.with(this).load(R.drawable.mijares_cascada).into(imgPrincipal);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
imgPrincipal.setImageTintList(getColorStateList(R.color.colorPrimaryLight));
}
imgPrincipal.setImageTintMode(PorterDuff.Mode.SCREEN);