我使用以下代码:
<android.support.v7.widget.CardView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardUseCompatPadding="true"
app:cardElevation="4dp">
<TextView android:text="in card view" android:layout_width="match_parent" android:layout_height="wrap_content"/>
</android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)
截图是:
如何只制作底部阴影?
如果你想要线性阴影,试试这个:
<View
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="@drawable/down_shadow"
/>
Run Code Online (Sandbox Code Playgroud)
down_shadow.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<gradient
android:angle="-90"
android:endColor="#EEEEEE"
android:startColor="#FFFFFF"
/>
</shape>
Run Code Online (Sandbox Code Playgroud)
另请参阅有关手动设置阴影的不同文章,如下所示: https: //medium.com/@ArmanSo/take-control-of-views-shadow-android-c6b35ba573e9。
| 归档时间: |
|
| 查看次数: |
3304 次 |
| 最近记录: |