#1 效果图:
#2 drawable:background.xml
<?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"
>
<shape android:shape="rectangle">
<gradient
android:angle="270"
android:startColor="#EC4032"
android:endColor="#FF9668"
/>
<corners
android:radius="6dp"
/>
</shape>
</item>
<item
android:bottom="10dp"
android:right="10dp"
>
<shape android:shape="rectangle">
<gradient
android:angle="270"
android:startColor="#FFFFFF"
android:endColor="#FFFFFF"
/>
<corners
android:radius="6dp"
/>
</shape>
</item>
</layer-list>
#3 xml布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray"
tools:context="com.bpj.shadow.MainActivity">
<TextView
android:layout_centerInParent="true"
android:id="@+id/tv"
android:layout_width="200dp"
android:layout_height="80dp"
android:gravity="center"
android:background="@drawable/backgroud"
android:text="我的高为80dp,宽为200dp,居中显示" />
<TextView
android:layout_below="@id/tv"
android:layout_width="200dp"
android:layout_height="20dp"
android:layout_marginTop="20dp"
android:layout_alignLeft="@id/tv"
android:gravity="center"
android:background="@android:color/background_light"
android:text="宽200dp" />
<TextView
android:layout_toRightOf="@id/tv"
android:layout_width="20dp"
android:layout_height="80dp"
android:layout_marginLeft="20dp"
android:layout_alignTop="@id/tv"
android:gravity="center"
android:background="@android:color/background_light"
android:text="高80dp" />
<TextView
android:layout_toLeftOf="@id/tv"
android:layout_width="50dp"
android:layout_height="10dp"
android:textSize="9sp"
android:layout_marginRight="20dp"
android:layout_alignBottom="@id/tv"
android:gravity="center"
android:background="@android:color/background_light"
android:text="10dp" />
</RelativeLayout>