Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android set android drawable for color

Tags:

android

I create a drawable.xml for some purpose , and i want to use this color:#29395e.

But i can't set up the #29395e in android:drawable .

I try to use <item android:color=" #29395e"/> , it can't compile.

Is any way i can use this color #29395e in this drawable ?

Any help will be grateful.

here is my drawable.xml:

<?xml version="1.0" encoding="utf-8"?>

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/corner_with_tab" android:state_selected="true" />
    <item android:drawable="@android:color/holo_blue_light"/>
</selector>
like image 327
Morton Avatar asked Jan 17 '17 08:01

Morton


People also ask

How do I change the color of a drawable in XML?

Use app:drawableTint="@color/yourColor" in the xml instade android:drawableTint="@color/yourColor" .

What is color drawable android?

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.

How can I change the color of my logo in android?

Search for and select Open App, and then, on the New Shortcut page, tap Choose. Locate the app whose appearance you want to change. Back on the New Shortcut page, you'll see the app name; tap More (three dots), change the app's name, tap its icon, select Color, and choose a new color.


1 Answers

Make a "colors.xml" resource file in res/values folder

<resources>
    <color name="colorName">#4da6ff</color>
</resources>

now in your mydrawable file use that color like this

 <item
    android:state_checked="true"
    android:drawable="@color/colorName" />
like image 98
Shuddh Avatar answered Oct 08 '22 09:10

Shuddh