I am having some trouble adding elevation for android version < 21. Recently I found it easy to add elevation on card view but I could not achieve the same result for other views like picture view, toolbar, drawer layout, etc. Can anyone help me with it???
For example: if I want to add elevation to my drawer layout as per the material design, what should I do?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@drawable/side_nav_bar"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:src="@drawable/ic_person_black_64dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:text="Android"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android studio" />
</LinearLayout>
One work around is that you can put all these view inside CardView
Just put LinearLayout
inside CardView
For example :-
<android.support.v7.widget.CardView
....
card_view:cardElevation="5dp"
card_view:cardCornerRadius="0dp">
<!-- other view that you want to elevate -->
<DrawerLayout ../> or <Toolbar ---->
</android.support.v7.widget.CardView>
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