Hello I am trying to add left drawable in Spinner
but I didn't find any propery for this as you do same in EditText
using android:drawableLeft="@drawable/password_drawable"
. Is there any correct way to achieve same in Spinner
in Android.
Here in my case there should be left drawable only this state which I gave in the screenshot, when user click on the Spinner I don't want to have left drawable there in open drop down list in Spinner
I'm trying like this where there is no such attribute
<Spinner
android:id="@+id/selectSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/sign_up_views_vertical_top_margin"
android:background="@drawable/edittext_border"
/>
I want something like below screenshot
Currently it is looking like below
and when I set the background of the Spinner
then it looks like
<Spinner
android:id="@+id/selectSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/sign_up_views_vertical_top_margin"
android:background="@drawable/selectone_drawable"
android:entries="@array/select_type" />
Thanks in advance
create a xml drawable @drawable/gradient_spinner `
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item><layer-list>
<item><shape>
<gradient android:angle="90" android:endColor="@color/myTextPrimaryColor" android:startColor="@color/myTextPrimaryColor" android:type="linear" />
<stroke android:width="1dp" android:color="@color/bg_eo" />
<corners android:radius="4dp" />
<padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
</shape></item>
<item ><bitmap android:gravity="right|center" android:src="@drawable/expnd" />
</item>
</layer-list></item>
</selector> `
set spinner background android:background="@drawable/gradient_spinner"
Create a nine-patch image and set it as the background of the Spinner, then add a left padding, should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With