I am using a library . In which I am showing the activity used by my library I am using a color to cover up the screen with color. it is looking cool.
But due to some reasons I have decided to use gradient. I have developed the beautiful gradient effect as you can see below
<?xml version="1.0" encoding="UTF-8"?>
<gradient
android:angle="90"
android:endColor="#555994"
android:centerColor="#b5b6d2"
android:startColor="#555994"
android:type="linear" />
<corners
android:radius="0dp"/>
</shape>
it is looking good. But problem is I am using library which only accepts the color or color resource. I have no other method to alter , the library is showing the activity it self , I just need to pass the color that will appear on the activity.
Now My question is :
Can I define directly the gradient color in the color.xml file. Or is there any way to convert the gradient color file which is in draw able , can be pick as a color. so that , the library can apply my custom gradient color as a back ground
please help me . It would be a grate help .
Edit 1:
For those guys who are saying me to add this as a background of the image or any thing else , let me share you a little part of that line so that you can understand the case more clearly
.withColorResource(R.color.indigo)
Here I am referencing to the purple color defined in the Color.xml, I can set any thing as a background as library only gives me option of setting color as shown above. So I have made a draw able of gradient color , Now I want that how to reference the gradient as a color.
Colors in Android are represented as
Int
(and I don't mean that asR.color.white
isInt
- that's just id of the color resource) which is just number representation of normal hex color, e.g.#f00
->0xFFFF0000
. That means that there is no way to represent gradient as single color resource.TLDR: gradient is not color but set of colors with angle.