Issue
I have this XML in my res/drawable directory:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item >
<shape android:shape="rectangle" >
<corners android:radius="10dip" />
<stroke android:width="1dip" android:color="#706969" />
<gradient android:angle="-90" android:startColor="#117e7a7a" android:endColor="#BB7e7a7a" />
</shape>
</item>
</selector>
I want to put in android:startColor="#117e7a7a"
a reference to a variable instead of a color value. ¿How can be that done? I can't find any info about that in google
Thanks
Solution
Here is explained how resources (such as color) can be referred to from other resources/layouts.
In short, use :
android:startColor="@color/myColor" ...
where "myColor" could be defined in values/colors.xml as :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="myColor">#117e7a7a</color>
.... more colors
</resources>
Answered By - kiruwka
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.