Android - Remove Spinner Dropdown Arrow

AndroidAndroid LayoutSpinnerAndroid SpinnerAndroid Selector

Android Problem Overview


I'm just wondering if it's at all possible to simply remove the dropdown arrow for a spinner? I have a drawable arrow in a backgroud layout for my spinner, however the system default arrow appears to the right of the spinner, which I would like to get rid of.

Here is the spinner xml code for my activity layout

<Spinner
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/spinnerSelectStaff"
            android:layout_gravity="center_horizontal"
            android:layout_marginLeft="18dp"
            android:layout_marginRight="18dp"
            android:gravity="center"
            android:dropDownSelector="@drawable/empty"/>

And my custom spinner layout looks like this:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@android:id/text1"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_margin="5dp"
          android:gravity="center"
          android:textSize="20sp"
          android:background="@drawable/spinner_text_shape"
          android:drawableRight="@drawable/ic_keyboard_arrow_down_black_24dp"
          android:textColor="@color/primary_text" />

Thanks!

Android Solutions


Solution 1 - Android

Background @null in the layout xml file also does the trick, if you don't want to declare a specific style:

        <Spinner
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"/>

Solution 2 - Android

This may help You

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style parent="@android:style/Widget.Spinner" name="SpinnerwithNoArrow">
        <item name="android:background">@android:drawable/edit_text</item>
    </style>
</resources>

Use this style in ur spinner

Solution 3 - Android

Please try this simple way:

android:background="@android:color/transparent"

Solution 4 - Android

Both answers were not helpful for me, so here is a really simple one-line solution that worked.

  //some spinner initialisation stuff->
mySpinner.setAdapter(adapter);

  //some spinner initialisation stuff->
mySpinner.getBackground().setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);

I can't tell for sure if it will work with just a default spinner layout, but it worked well with my custom that I created for other needs.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMetalorView Question on Stackoverflow
Solution 1 - AndroidGalyaView Answer on Stackoverflow
Solution 2 - AndroidPrabhurajView Answer on Stackoverflow
Solution 3 - AndroidNimisha VView Answer on Stackoverflow
Solution 4 - AndroidNor NewmanView Answer on Stackoverflow