2016-07-08 11 views
-4

スピナーをクリックした後に表示されるポップアップリストのテキストの色とサイズを変更することができます。アイテムを選択した後、アイテムはスピナーにセットされます。スピンナー上でこのアイテムのテキストサイズを変更する必要があります。助けてください...ポップアップウィンドウではなく、スピナーのテキストサイズと色を変更するにはどうすればよいですか?

+0

の可能性のある重複した[スピナーテキストサイズや文字色を変更する方法?](http://stackoverflow.com/questions/9476665/how-to-change-spinner-text -size-and-text-color) –

+0

@Amit Vaghela、私はポップアップウィンドウでテキストをカスタマイズする必要はありません。このソリューションは、ポップアップウィンドウのテキストのカスタマイズについて議論します。 –

答えて

0

の方法でスピナーをカスタマイズするには、以下のアダプターコンストラクターを使用してください。

spinnerAdapter = new ArrayAdapter(this, R.layout.row_spinner 
      /* The resource ID for a layout file containing a layout to use when 
       instantiating views. */ ,android.R.id.text1, array); 

そして、あなたは

spinnerAdapter.setDropDownViewResource(R.layout.layout_spinner); 

サンプルレイアウト

row_spinner

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@android:id/text1" 
    style="?android:attr/spinnerDropDownItemStyle" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:ellipsize="marquee" 
    android:gravity="center" 
    android:singleLine="true" 
    android:textColor="@color/colorBlack" 
    android:textColorHint="@color/colorBlack" 
    android:textSize="@dimen/text_size_l"/> 
を使用してビューのドロップダウンを定義するレイアウトリソースを設定することができます

layout_spinner

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@android:id/text1" 
    style="?android:attr/spinnerDropDownItemStyle" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/margin_padding_width_height_6" 
    android:ellipsize="end" 
    android:gravity="center" 
    android:singleLine="true" 
    android:textColor="@color/colorBlackLight" 
    android:textSize="@dimen/text_size_l"/> 
関連する問題