I have the following colors:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="darkgray">#404040ff</drawable>
<drawable name="black">#000ff</drawable>
<drawable name="red">#ff00ff</drawable>
<drawable name="green">#0ff0ff</drawable>
<drawable name="lightgray">#c0c0c0ff</drawable>
<drawable name="white">#ffffffff</drawable>
<drawable name="yellow">#ffff0ff</drawable>
<drawable name="blue">#00ffff</drawable>
<drawable name="gray">#808080ff</drawable>
<drawable name="magenta">#ff0ffff</drawable>
<drawable name="cyan">#0ffffff</drawable>
</resources>
And I have the following in my Main Layout file for a Button background color: (snippet)
<Button
android:id="@+id/widget27"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/yellow"
android:text="Button"
android:layout_x="30px"
android:layout_y="102px"
>
</Button>
My question is: What do I name the file with the colors, and where do I put it? I am getting a compile error, aresgen exit error.
I'm looking for a filename and location where the background colors can be accessed.
Thanks,
android.graphics.drawable.ColorDrawable. A specialized Drawable that fills the Canvas with a specified color. Note that a ColorDrawable ignores the ColorFilter. It can be defined in an XML file with the <color> element.
You can use android:drawableTint="@color/yourColor" in >23 android version.
Use app:drawableTint="@color/yourColor" in the xml instade android:drawableTint="@color/yourColor" . It has the backward compatibility.
You should create an XML file at in res/values/colors.xml
-- store all your colors in here.
Additionally, you should read this whole page, but here is the section that directly relates to your question:
http://developer.android.com/guide/topics/resources/more-resources.html#Color
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With