I looking for some solutions and try to complete it. The divider still doesn't show out.
I have set style for my theme in styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Others theme here. -->
<item name="android:dropDownListViewStyle">@style/mySpinnerStyle</item>
</style>
Here is mySpinnerStyle
<style name="mySpinnerStyle" parent="android:Widget.ListView.DropDown">
<item name="android:divider">#00ff00</item>
<item name="android:dividerHeight">1dp</item>
</style>
Here is my fragment code for spinner:
Spinner chooseDate = (Spinner) view.findViewById(R.id.chooseDate);
String[] date_group = dateList.toArray(new String[dateList.size()]);
ArrayAdapter<String> itemDate = new ArrayAdapter<String>(getActivity(), R.layout.spinner, date_group);
itemDate.setDropDownViewResource(R.layout.spinner);
chooseDate.setAdapter(itemDate);
Here is my spinner layout xml:
<Spinner
android:theme="@style/mySpinnerStyle"
android:spinnerMode="dialog"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_marginRight="16dp"
android:id="@+id/chooseDate"
android:layout_width="match_parent"
android:layout_height="38dp"
android:background="@drawable/spinner_arrow" />
And then R.layout.spinner xml is like this:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:textSize="22dp"
android:theme="@style/mySpinnerStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:gravity="center"
android:paddingRight="40dp"
android:singleLine="true" />
I click my spinner shows dialog like this that is no divider in the end...
I have set style for my spinner but i can't show divider. I don't know why ?
Any help would be appreciated . Thanks in advnace.
Manifests use my AppTheme:
<application
android:allowBackup="true"
android:icon="@drawable/app_icon_512x512"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:name="android.support.multidex.MultiDexApplication">
Remove the android:theme="@style/mySpinnerStyle"
from your TextView
(R.layout.spinner xml)
And change this value from your spinner
android:spinnerMode="dialog"
Use this value
android:spinnerMode="dropdown"