Search code examples
androiddrawablenine-patchandroid-spinner

Spinner with custom background not showing text


I have a pair of Spinners that work exactly as intended, but when I put a drawable on them, the text just dissapears. Here is the XML of both the Layout and the Drawable. The only problem here is that the drawable does not let the text show up.

ttd_list.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >

<include
    android:id="@+id/include1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    layout="@layout/action_bar" />

<LinearLayout
    android:id="@+id/ll1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" android:background="@color/gray">

    <RelativeLayout
        android:id="@+id/relativeLayout1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="beforeDescendants"
        android:focusableInTouchMode="true"
        android:paddingBottom="8dip" >

        <AutoCompleteTextView
            android:id="@+id/autoCompleteThingsToDo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_marginTop="8dip"
            android:layout_toLeftOf="@+id/buttonSearchThingsToDo"
            android:textColor="#000000" >
        </AutoCompleteTextView>

        <Button
            android:id="@+id/buttonSearchThingsToDo"
            style="@style/StandardButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/autoCompleteThingsToDo"
            android:text="@string/search" />
    </RelativeLayout>

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="8dip" >

        <Spinner
            android:id="@+id/spinnerCategories"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/spinner_filters" />

        <View
            android:layout_width="10dip"
            android:layout_height="match_parent" />

        <Spinner
            android:id="@+id/spinnerSortOrder"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@drawable/spinner_filters" />
    </TableRow>
</LinearLayout>

<ListView
    android:id="@+id/listViewThingsToDo"
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_weight="1" >
</ListView>

spinner_filters.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@drawable/spinnerbg" android:state_pressed="true"><shape>
        <solid android:color="@color/blue" />

        <stroke android:color="@color/blue" />

        <corners android:radius="3dp" />
    </shape></item>
<item android:drawable="@drawable/spinnerbg" ><shape>
        <solid android:color="#00000000" />

        <corners android:radius="3dp" />
    </shape></item>

</selector>

spinnerbg.9.png:

enter image description here

Any idea on why doesn't the text show up?

EDIT: OK, already solved it. The problem lied in the 9.png file, it wasn't designed properly.


Solution

  • The text inside may be in white color. Try to change the color of your background, to be sure...