私は、アンドロイドアプリケーションを開発しているので、スピナーの背景色とテキストの色を変更したいのですが? ありがとう。
回答:
回答№1は0テキストの色とスタイルを変更するには: xmlレイアウトを作成するspinner_text.xmlには次が含まれます:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:textSize="18sp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:textColor="@android:color/black" />
クラスの設定でそれを使用するArrayAdapter:
Spinner yourSpinner = (Spinner) findViewById(R.id.spinnerID);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), R.layout.spinner_text, yourStingArray);
yourSpinner.setAdapter(adapter);
xmlのスピナーの背景を変更する:
<Spinner
android:layout_width="fill_parent"
android:layout_height="40dp"
android:id="@+id/sCategory"
android:entries="@array/angleList"
android:background="@drawable/spinner_shape"
android:layout_marginBottom="10dp"
android:popupBackground="@drawable/spinner_shape" />
drawableで必要なものを実行します:spinner_shape
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/colorFour" />
<stroke
android:color="@color/colorTwo"
android:width="2dp" />
<corners
android:bottomLeftRadius="4dp"
android:bottomRightRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp" />
android:popupBackgroundはドロップ項目リストの表示を行います アンドロイド:背景がスピナーの外観をする