Vector drawable of image contains Gradient
colors, which are not showing in imageview
for below API version of 24, i am using Android-Studio 3.1
ic_gradient_image.xml :
<aapt:attr name="android:fillColor">
<gradient android:endX="270.1115" android:endY="1.3445"
android:startX="243.3148" android:startY="512.6555" android:type="linear">
<item android:color="#FFFF9426" android:offset="0"/>
<item android:color="#FF9D6936" android:offset="0.4076"/>
<item android:color="#FF404146" android:offset="0.8154"/>
<item android:color="#FF1B314C" android:offset="1"/>
</gradient>
</aapt:attr>
Above xml
shows,
Attribute
endX
is only used in API level 24 and higher.Attribute
endY
is only used in API level 24 and higher.Attribute
offset
is only used in API level 24 and higher.
build.gradle :
vectorDrawables.useSupportLibrary = true
Application.java :
static
{
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
Implemented in adapter :
holder.product_image.setImageResource(R.drawable.ic_gradient_image);
Also tried,
holder.product_imageButton.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_gradient_image));
I have tried Solution1 and Solution 2
Is there any way to reflect gradient
colors in imageview
under API 23 with Android Studio 3.0.