android - change color of spinner items -
how change text color of spinner item ithout custom adapter
styles.xml
<style name="mytheme1" parent="theme.appcompat.light"> <item name="android:textappearancelistitemsmall">@style/myspinnerstyle</item> </style> <style name="myspinnerstyle" parent="textappearance.appcompat.subhead"> <item name="android:textsize">13sp</item> <item name="android:textcolor">@color/white</item> </style>
i adding style spinner
<spinner style="@style/myspinnerstyle" android:id="@+id/cases" android:layout_width="wrap_content" android:layout_height="60dp" android:layout_alignparentbottom="true" android:layout_alignparentstart="true" android:dropdownverticaloffset="60dp" android:entries="@array/main_array" />
you need create layout textview
<?xml version="1.0" encoding="utf-8"?> <textview xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:textsize="18sp" android:gravity="left" android:textcolor="what_ever_color_you want_specify_here" android:padding="5dp" />
inflate layout using spinner
adapter
arrayadapter<string> adapter = new arrayadapter<string>(this, r.layout.your_custom_layout,list);
Comments
Post a Comment