GuybrushThreepwood GuybrushThreepwood - 1 month ago 9
Java Question

Creating State List Drawable XML for Background - Android

I am trying to get the following state list to work. The idea is to create a white background.

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_selected="true"
android:drawable="@android:color/transparent" />
<item android:state_selected="true" android:drawable="@android:color/transparent" />
<item android:state_pressed="true" android:state_selected="false"
android:drawable="@android:color/transparent" />
<item android:state_selected="false" android:drawable="@color/WHITE" />
</selector>


When I try and compile this I get the following error..

@color/transparent and @color.WHITE don't exist.


Do I need to define these somewhere and if so how ?

Thanks !

Answer

try to create a resource file like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#ffffff</color>
</resources>

let's see if someone knows about transparent one

Comments