I have a spinner(dropdown)
I want to align the text in the spinner to the center and also want to change its colour to white. How can i achieve it???
Spinner.Xml
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/sp_age"
android:layout_weight="1"
style="@style/spinner"
android:layout_margin="2dp"
android:spinnerMode="dropdown"></Spinner>
Style.Xml
<style name="spinner">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:popupBackground">#df382e1c</item>
<item name="android:layout_marginTop">-12dp</item>
<item name="android:background">@drawable/dropdown</item>
<item name="android:textColor">#fff</item>
<item name="android:textSize">50sp</item>
</style>
Spinner.Java
gender_array=getResources ().getStringArray (R.array.Gender);
gender_str= new ArrayAdapter<String> (c,android.R.layout.simple_spinner_dropdown_item,gender_array);
gender_str.setDropDownViewResource (android.R.layout.simple_dropdown_item_1line);
gender.setAdapter (gender_str);
check_textview.xml
Create a separate layout like
and change the two lines
to
You have to pass layout on adapter.
Use below code:-
spinner_layout.xml