3

I have a spinner in android , and i use spinner background . But now the problem is ,my image got a down arrow on it, and android add another down arrow or something like that. Now i want to remove android default arrow icon.
Here is the image enter image description here

Android java code

ArrayAdapter<String> dataAdapterOfFromAccount = new ArrayAdapter<String>(context,
                R.layout.custom_simple_spinner, accountList);
        dataAdapterOfFromAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spFromAccount.setAdapter(dataAdapterOfFromAccount);


custom_simple_spinner.xml for custom layout

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"

android:layout_width="match_parent"
android:layout_height="50dp"
android:ellipsize="marquee"
android:gravity="center_vertical"

android:paddingRight="35dp"
android:background="@drawable/btn_selector" />

I use this style Code

<style name="mySpinnerStyle" parent="@android:style/Widget.Spinner">
    <item name="android:divider">#01579B</item>
    <item name="android:dividerHeight">1dp</item>


</style>

Now pls, can anyone help me with this, I want to remove those default dropdown icon . Thanks in advance . I am using Android 6.0 (API Level 23) It was good at Android 5(API level 22) , but creates problem in Android 6.

Sohel0415
  • 9,523
  • 21
  • 30
  • 2
    you can refer to this link http://stackoverflow.com/questions/4058360/how-to-create-android-spinner-without-down-triangle-on-the-right-side-of-the-wid – Sandeep Londhe Oct 30 '15 at 14:26

2 Answers2

4

Hide dropdown icon

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

or cover another view

<RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content">

  <Spinner
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_centerVertical="true"/>

  <ImageView
      android:layout_width="30dp"
      android:layout_height="30dp"
      android:layout_alignParentEnd="true"
      android:layout_centerVertical="true"
      android:background="#fff"/>
</RelativeLayout>
Hun
  • 3,652
  • 35
  • 72
0

You can use your own style

 <style parent="@android:style/Widget.Spinner" name="mySpinnerStyle">
   <item name="android:background">@android:drawable/edit_text</item>
  </style>

And also try change your code from

style="?android:attr/spinnerItemStyle"

to:

style="@style/mySpinnerStyle"
Max
  • 711
  • 5
  • 13