2
I’m trying to place a line dividing the items I have in a Spinner
but I can’t seem to get it out.
spinner_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="@style/spinnerItemStyle"
android:maxLines="1"
android:textColor="@color/grey_default"
android:textStyle="bold"
android:textSize="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee" />
spinner_dropbox.xml
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="@style/spinnerDropDownItemStyle"
android:maxLines="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee" />
Styles.xml
<style name="spinnerItemStyle" parent="android:Widget.TextView.SpinnerItem"/>
<style name="spinnerDropDownItemStyle" parent="Widget.AppCompat.ListView.DropDown">
<item name="android:dividerHeight">2dip</item>
<item name="android:divider">#808080</item>
</style>
Mainactivity (...)
//adapter creation categorias
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_item, list_categorias);
adapter.setDropDownViewResource(R.layout.spinner_dropbox);
categoria.setAdapter(adapter);
What I’m getting is this:
Can anyone help us? Why not draw the line between the various items?
I can’t understand the answer. In Styles.xml I have set the spinnerDropDownItemStyle which is then associated with spinner_dropbox. This spinner_dropbox is later called in java.
– porthfind
The style should not be associated with the spinner_dropbox but in the application’s Theme style.
– ramaral
Thank you! It’s worked.
– porthfind