i use following code:
<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>
the screenshot is:
how to make only bottom show shadow?
Customized CardView First, add a CardView dependency to the application-level build. gradle file. Then create a drawable background for the cards. For that, create a new drawable resource file inside the drawable folder.
To change CardView's elevation in a backward compatible way, use setCardElevation . CardView will use elevation API on Lollipop and before Lollipop, it will change the shadow size. To avoid moving the View while shadow size is changing, shadow size is clamped by getMaxCardElevation .
CardView is a new widget in Android that can be used to display any sort of data by providing a rounded corner layout along with a specific elevation. CardView is the view that can display views on top of each other. The main usage of CardView is that it helps to give a rich feel and look to the UI design.
If you want a linear shadow, try this:
<View
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="3dp"
android:background="@drawable/down_shadow"
/>
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>
See also different articles for manual setting of shadows like this: https://medium.com/@ArmanSo/take-control-of-views-shadow-android-c6b35ba573e9.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With