在Android中,可以使用elevation
屬性來(lái)設(shè)置陰影效果。elevation
屬性是View類中的一個(gè)屬性,用于設(shè)置View的Z軸高度,從而產(chǎn)生陰影效果。例如:
<View
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="8dp"
android:background="@android:color/white"/>
在上面的例子中,elevation
屬性設(shè)置為8dp
,表示View的Z軸高度為8dp,從而產(chǎn)生一個(gè)陰影效果。可以根據(jù)需要調(diào)整elevation
的數(shù)值來(lái)控制陰影的深淺程度。
另外,如果要設(shè)置View的邊框,可以使用Stroke
屬性和StrokeColor
屬性來(lái)實(shí)現(xiàn)。例如:
<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
屬性設(shè)置為2dp
,表示邊框的寬度為2dp,strokeColor
屬性設(shè)置為@android:color/black
,表示邊框的顏色為黑色??梢愿鶕?jù)需要調(diào)整strokeWidth
和strokeColor
的數(shù)值來(lái)設(shè)置邊框的樣式。