Reputation: 9853
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
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.
Upvotes: 3
Views: 8373
Reputation: 3798
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>
Upvotes: 4
Reputation: 701
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"
Upvotes: 0