0

I want to remove down triangle on the right side and wants to bottom line. I am using following code to add bottom line:

<Spinner
android:id="@+id/buttonSelectCountry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:gravity="center"
android:spinnerMode="dropdown"
android:text="Select country"
style="@style/Widget.AppCompat.Spinner.Underlined"/>

and following code to remove down arrow:

<Spinner
android:id="@+id/buttonSelectCountry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:gravity="center"
android:spinnerMode="dropdown"
android:text="Select country"
style="@style/Widget.AppCompat.Spinner.Underlined"
android:background="#FFFFFF"/>

But using above code the bottom line also gets invisible.

How can I do this.

M. Wiśnicki
  • 6,094
  • 3
  • 23
  • 28
Faisal Shaikh
  • 3,900
  • 5
  • 40
  • 77

3 Answers3

1
<?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
   <item>
    <layer-list>
        <item>
            <shape >
                <corners android:radius="5dp" />
                <!--<padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />-->
                <solid android:color="@color/bgcolor"/>
            </shape>
        </item>
        <item>
            <bitmap android:gravity="bottom|center" android:src="@drawable/ninepatchline" />
        </item>
    </layer-list>
  </item>
</selector> 

Set this drawable as Background of the spinner

UPDATE

Add paddingBottom to spinner.

android:paddingBottom="@dimen/min_padding"

Noorul
  • 3,386
  • 3
  • 32
  • 54
0

You can use a custom background in drawable folder which have a bottom line in it.

bottom_line.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape>
            <solid
                android:color="#000000" />
            <padding
                android:bottom="1dp" />
        </shape>
    </item>
    <item>
        <shape>

            <solid android:color="#FFFFFF"/>
        </shape>
    </item>
</layer-list>

put this as your background to spinner :

<Spinner
    android:id="@+id/buttonSelectCountry"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:layout_centerHorizontal="true"
    android:spinnerMode="dropdown"
    android:text="Select country"
    android:background="@drawable/bottom_line"/>
Manishika
  • 5,478
  • 2
  • 22
  • 28
0

You can simply add background to your spinner. if your main background is white than you can simply set your spinner background as follow with white color code or any relevant color code you want that matches your main background.

<Spinner
android:id="@+id/buttonSelectCountry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:gravity="center"
android:text="Select country"
android:background="#FFFFFF"/>

Replace this code with yours.

Chirayu
  • 193
  • 1
  • 11