将阴影放在圆形按钮中

时间:2014-07-07 08:41:05

标签: android android-layout

您好,我需要一些帮助,如何在我的圆形按钮上添加阴影。这是我的代码

 <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle" >

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

        <corners
            android:bottomLeftRadius="56dip"
            android:bottomRightRadius="56dip"
            android:topLeftRadius="56dip"
            android:topRightRadius="56dip" />


    </shape>

1 个答案:

答案 0 :(得分:0)

试试这个......

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:left="5dp" android:top="5dp">  <!-- shadow effect -->
        <shape>
            <corners android:radius="10dp" />
            <solid android:color="#888888" />
        </shape>
    </item>

    <item android:bottom="3dp" android:right="3dp">  <!-- Button Shape -->
        <shape android:shape="rectangle">
            <solid android:color="#55fff000"/>
            <corners android:radius="10dp" />

            <padding android:left="10dp"
                android:right="10dp"/>
            <stroke android:width="3px" 
                android:color="@color/border_pink" />
        </shape>
    </item>

</layer-list>