コードで丸い長方形を描く場合、setShadowLayerを使用してその形状に影を描くことができます。XMLで形状を定義するときに同等のものはありますか?
次の例では、丸い長方形の背景を図形に描画します。シェイプに影を追加するには、何を追加する必要がありますか?XMLを使用することも可能ですか?
shape_test.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#8067BF6A"/>
<stroke android:width="3dp" android:color="#80000000" />
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp" />
<corners android:bottomRightRadius="7dp"
android:bottomLeftRadius="7dp"
android:topLeftRadius="7dp"
android:topRightRadius="7dp"/>
</shape>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:background="#ffdddddd"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button android:background="@drawable/shape_test"
android:padding="5dp"
android:textStyle="bold"
android:textSize="28sp"
android:text="Hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>