我有一對Spinners完全按照預期工作,但是當我在它們上面放置可繪圖時,文本消失。這是Layout和Drawable的XML。這裏唯一的問題是drawable不讓文本顯示出來。自定義背景的微調框不顯示文字
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:
關於爲什麼不顯示文字的任何想法?
編輯:好的,已經解決了。問題出在9.png文件中,它的設計不正確。
你能詳細說明問題是什麼嗎?我面臨同樣的問題。 – Niels
@Niels這是一個簡單的問題:你只需要用sdk工具編輯你的9.png。你必須把包含文本的像素向下和向右。 – razielsarafan