スピナーポップアップの背景色を設定しようとしていますが、試したすべてが正しく機能しませんでした。
これはスピナーコントロールです:
<Spinner
android:id="@+id/myspinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@null"
android:drawSelectorOnTop="true" />
クリックすると背景が白のポップアップが表示されるので、変更したいのですが。
ポップアップを作成するために使用するxml行は次のとおりです。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/list_selector"
android:paddingBottom="@dimen/padding_medium"
android:layout_marginBottom="@dimen/padding_medium"
android:orientation="vertical">
..........
</RelativeLayout>
および描画可能な背景list_selector.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Pressed -->
<item
android:state_pressed="true"
android:drawable="@color/green" /> <!-- @drawable/tab_press -->
<!-- Selected -->
<item
android:state_selected="true"
android:drawable="@color/green" /> <!-- @drawable/tab_press -->
</selector>
上記のxmlにデフォルトの状態を追加することは問題ありませんが、スピナーのメインコントロールはその背景色でアイテムを表示するので、それは望ましくありません。
私が試したもう1つのことは、styles.xmlでアプリケーションの背景色を黒に設定することです。
<style name="AppTheme" parent="android:Theme.Light">
<item name="android:background">#000000</item>
<item name="android:textColor">#FFFFFF</item>
<item name="android:typeface">sans</item>
</style>
これもポップアップの背景を上書きしますが、望ましくない付随的な影響があります。これを簡単な方法で達成する方法はありますか?
PS:APIレベル10(2.3.3)を使用していますが、属性android:popupBackground
が存在しません。