membersound
membersound

Reputation: 86747

Use build in colors in xml?

How can I make use of android.grapics.color constants? http://developer.android.com/reference/android/graphics/Color.html

This does not work:

android:drawable="@android:color/cyan"

Upvotes: 0

Views: 297

Answers (2)

Snicolas
Snicolas

Reputation: 38168

android.R.provides these colors.

If you want to use the Color class, you need some java code :

view.setBackgroundColor( Color.CYAN );

Upvotes: 3

Brayden
Brayden

Reputation: 519

Why are you setting a color to android:drawable. Are you trying to set a background? Because then you'd use:

android:background="@android:color/black"

Although in my editor I don't see cyan as an option. If you just cntrl+space in the xml field, you can pick @android:color/ and then pick a color. You can always make your own in the colors.xml file though :)

Upvotes: 0

Related Questions