Top Menu

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday 30 September 2015

Create Custom Spinner with background shape

Hello Guys,

If you are looking for creating Custom Spinner like this
enter image description here

Then I am here to help you :-)
Create an XML in drawable folder with any name for example spinner_bg.xml and add the following lines
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <layer-list>
            <item>
                <shape>
                    <stroke android:width="3dp" android:color="#ebebeb" />

                    <corners android:radius="5dp" />

                    <solid android:color="#fff"></solid>
                </shape>
            </item>
            <item>
                <bitmap android:gravity="bottom|right" android:src="@drawable/ic_arrow_drop_down" />
            </item>
        </layer-list>
    </item>
</selector>
Add the following lines to your styles.xml which is inside values folder
<style name="spinner_style" >
    <item name="android:background">@drawable/spinner</item>
    <item name="android:popupBackground">#DFFFFFFF</item>
</style>
Now add this style to your spinner as

<Spinner
    android:id="@+id/condition"
    style="@style/spinner_style"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:layout_marginTop="15dp"
    android:popupBackground="#cccccc" />




1 comment:

  1. Thanks Saranya!! for appreciate my post.
    Let me know if I can do anything else for you.

    ReplyDelete