在Android中,可以使用elevation屬性來設置陰影效果。elevation屬性是View類中的一個屬性,用于設置View的Z軸高度,從而產生陰影效果。例如:
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="8dp"
android:background="@android:color/white"/>
在上面的例子中,elevation屬性設置為8dp,表示View的Z軸高度為8dp,從而產生一個陰影效果??梢愿鶕枰{整elevation的數值來控制陰影的深淺程度。
另外,如果要設置View的邊框,可以使用Stroke屬性和StrokeColor屬性來實現。例如:
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:strokeWidth="2dp"
android:strokeColor="@android:color/black"/>
在上面的例子中,strokeWidth屬性設置為2dp,表示邊框的寬度為2dp,strokeColor屬性設置為@android:color/black,表示邊框的顏色為黑色??梢愿鶕枰{整strokeWidth和strokeColor的數值來設置邊框的樣式。