1

I want to show spinner with a underline and a custom right arrow as shown below. enter image description here

I am setting below drawable as a background to spinner.

<item>

    <layer-list>

        <item>
            <color android:color="@android:color/white" />
        </item>

        <item android:drawable="@drawable/ic_spinner_dropdown" android:drawableTint="@color/dark_grey" android:gravity="center_vertical|right"></item>
        <item android:gravity="bottom">
            <shape>
                <size android:height="1dp" />
                <solid android:color="@color/grey" />
            </shape>
        </item>
    </layer-list>

</item>

It works for some devices but in some devices arrow appears on complete spinner with grey background like this- enter image description here

I am testing with Asus phone with API 21 in which I am facing this issue.

I am using below code in layout-

                <Spinner
                    android:id="@+id/spinner_choose_question"
                    style="@style/Widget.App.Spinner"
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="@dimen/dp_16"
                    android:layout_marginTop="@dimen/dp_58"
                    android:layout_marginRight="@dimen/dp_16"
                    app:layout_constraintLeft_toLeftOf="parent"
                    app:layout_constraintRight_toRightOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/tip_confirm_password"/>

styles.xml

<style name="Widget.App.Spinner" parent="@style/Base.Widget.AppCompat.Spinner.Underlined">
    <item name="overlapAnchor">true</item>
    <item name="android:background">@drawable/spinner_background</item>
</style>
Android Developer
  • 9,157
  • 18
  • 82
  • 139
  • Possible duplicate of [How to change the spinner background design and color for android?](https://stackoverflow.com/questions/11188398/how-to-change-the-spinner-background-design-and-color-for-android) – ADM Apr 13 '19 at 06:46
  • @ADM I have already checked it and implemnted code..My code works for some devices but in few devices i face issue..So its not duplicate – Android Developer Apr 13 '19 at 06:48
  • Well then Mention these some devices with question . OS Version Specifically .. – ADM Apr 13 '19 at 06:48
  • @ADM I already mentioned some devices in question.I'll add OS – Android Developer Apr 13 '19 at 06:50
  • I asked Which some devices ? What OS versions ? Just skip using Style once and Use one of answer in above link. See the output – ADM Apr 13 '19 at 06:52
  • @ADM I am testing with Asus phone with API 21 in which I am facing this issue. – Android Developer Apr 13 '19 at 07:24

1 Answers1

1

-Try adding style to spinner as shown below.

<Spinner
    android:layout_width="150dp"
    android:layout_height="40dp"
    android:popupBackground="#ffffff"
    android:dropDownVerticalOffset="30dp"
    style="@style/Base.Widget.AppCompat.Spinner.Underlined"/>