需求應(yīng)用場景如下:

需求? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
我們知道android5.0以上,我們可以通過cardView實(shí)現(xiàn),?
app:cardElevation="20dp"
app:cardCornerRadius="10dp"
這兩行代碼就可以實(shí)現(xiàn)圓角和陰影效果,但是不巧,我這個(gè)代碼是以前寫的使用RelativeLayout實(shí)現(xiàn)的,我又不想改成cardView
怎么辦,其實(shí)只要在RelativeLayout中加上
android:elevation="3dp"
就可以了,這樣RelativeLayout就有陰影效果了。
圓角效果,background指定圓角背景即可,代碼如下:
? ? android:layout_width="match_parent"
? ? android:layout_height="wrap_content"
? ? android:background="@drawable/item_shape"
? ? android:orientation="vertical"
? ? android:elevation="3dp"/>
圓角背景:item_shape.xml
? ? android:shape="rectangle">
? ? android:width="0.5dip"
? ? android:color="#ffffff" />