Sunday, October 20, 2013

Create custom button with round corner and shadow by XML

To create a button in Android app like this:


The layout XML:
<Button

    android:layout_width="match_parent"

    android:layout_height="80dip"

    android:background="@drawable/hi"

    android:text="@string/click_button"

    android:textColor="#999"

    android:textSize="18dip"

    android:textStyle="bold" />
The drawable file hi.xml:
<?xml version="1.0" encoding="utf-8"?>

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

    <!-- Bottom 2dp Shadow -->

    <item android:bottom="11px" android:top="19px" android:left="10px" android:right="10px">

        <shape android:shape="rectangle" >

            <solid android:color="#ccc" />

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

        </shape>

    </item>

    <!-- White Top color -->

    <item android:bottom="15px" android:top="15px" android:left="10px" android:right="10px">

        <shape android:shape="rectangle" >

            <solid android:color="#FFFFFF" />

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

        </shape>

    </item>

</layer-list>

1 comment:

Thrift fails on Windows - thrift failed error: The command line is too long.

Meet a thrift compiling failure on my project on Windows 7. Using Maven in IntelliJ so I choiced maven-thrift-pluging for thrift files. For ...