Toshi Toshi - 3 years ago 245
Android Question

Design XML Button Android

Here is an example of an app that used XML to design button.

How can i have the same

design with XML
?

How make my buttons
look like it is floating
just like in the image below?

Sample

Answer Source

I think you will need to use a shape drawable with a layered list, here is an example of a button that has a different color on the top and bottom (the drop shadow effect). You will set this as the background attribute of the Button.

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item>
        <shape android:shape="rectangle" >
            <corners android:radius="2dp" />

            <solid android:color="@color/button_border_dark" />
        </shape>
    </item>
    <item android:top="1dp">
        <shape android:shape="rectangle" >
            <corners android:radius="2dp" />

            <solid android:color="@color/button_border_light" />
        </shape>
    </item>
    <item
        android:bottom="1dp"
        android:top="1dp">
        <shape android:shape="rectangle" >
            <corners android:radius="2dp" />

            <solid android:color="@color/button_general_color" />
        </shape>
    </item>

</layer-list>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download