Currently I have 3 drawable XML files defining 3 separate gradients. these gradients are dynamically set as the background color of an imageView in my code (which is working fine).
example: drawable\morningsky.xml
<?xml version="1.0" encoding="utf-8"?>
<item android:bottom="4dp">
<shape>
<gradient
android:startColor="@color/blue"
android:endColor="@color/dark_blue"
android:angle="270" />
</shape>
example: drawable\eveningsky.xml
<?xml version="1.0" encoding="utf-8"?>
<item android:bottom="4dp">
<shape>
<gradient
android:startColor="@color/orange"
android:endColor="@color/yellow"
android:angle="270" />
</shape>
I am setting the backgrounds in my imageView this way:
iv.setBackgroundResource(R.drawable.morningsky);
All is good, but do I really need to use multiple different drawable resource files for each gradient? Is there any way I can define all gradients in one single drawable file and then load that gradient from my code?