2016-04-02 10 views
1

私は項目のいくつかのリストを持っている1つのスピナーを使用しています。私は項目のテキストの色とテキストサイズを変更したい。私はリストを埋めるためにアンドロイドのエントリを使用しています。スピナーリスト項目のテキストサイズとテキストの色を変更するにはどうすればよいですか?

スピナーコード:

<Spinner 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="right" 
      android:textColor="#456789" 
      android:popupBackground="@color/title" 
      android:background="@drawable/ic_action_overflow" 
      android:entries="@array/spinnerItems"/> 
+0

「SpinnerAdapterによって制御されるアイテムのテキストの色とテキストサイズを変更します。 – CommonsWare

+0

カスタムテキストビューxmlを作成し、そのテキストビューを 'Spinner Adapter'で使用します。 –

答えて

0

カスタムスピナーアイテムビューを作成する必要があります。ここのI.Eはsimple_spinner_item.xmlです。

<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@android:id/text1" 
style="?android:attr/spinnerItemStyle" 
android:singleLine="true" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:ellipsize="marquee" 
android:textAlignment="inherit"/> 

そこから、そのビューをアダプターに渡す必要があります。例:

new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, new String[] {context.getString(R.string.item1), context.getString(R.string.item2)}); 
+0

ありがとうございます!それは私の問題を解決した。 –

関連する問題