Nếu tôi vẽ hình dạng vòng tròn theo mã, tôi có thể sử dụng setShadowLayer để vẽ bóng cho hình dạng. Có tương đương khi xác định các hình dạng trong XML không?Có tương đương với setShadowLayer khi xác định hình dạng trong XML trong Android không?
Ví dụ sau đây vẽ một nền thẳng tròn thành hình dạng. Tôi cần thêm gì để thêm bóng vào hình dạng? Thậm chí có thể sử dụng XML không?
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>