android-elevation
How to change direction of android elevation shadow?
I consider this method is the best solution: Android Bottom Navigation Bar with drop shadow Thanks, Alexander Bilchuk. Solution: You can draw your own shadow just above the view using simple View and its background: <View android:layout_width=”match_parent” android:layout_height=”4dp” android:layout_above=”@id/bottom_bar” android:background=”@drawable/shadow”/> drawable/shadow.xml: <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <gradient android:startColor=”#1F000000″ android:endColor=”@android:color/transparent” android:angle=”90″ /> </shape> Also, there are no compatibility issues … Read more
Difference between elevation and translationZ
That is because the actual Z value is the sum of the elevation and the translationZ From the docs, the elevation is “base z depth of the view” and this is a static variable, while translationZ is dynamic. So elevation is your start value and for animations you should use translationZ. Source
Material TabLayout elevation not working
To make the shadow show, you have to set a background on your TabLayout. It can be the same color as your window background (as long as it’s a solid color with no alpha). <android.support.design.widget.TabLayout android:id=”@+id/tab_layout” android:layout_width=”match_parent” android:layout_height=”?attr/actionBarSize” android:elevation=”6dp” android:background=”@color/white” />
Elevation not working for ImageView
The elevation shadow is derived from the background drawable of a View. If your ImageView has no background, you’ll see no shadow. If you want to change that behavior, you need to build your own ViewOutlineProvider and call View.setOutlineProvider() to set it (and this is not trivial).
android:elevation only have shadow effects on the bottom side, how to make the shadow effects show on top side?
There is a trick that can be used to display a shadow above a View. Basically we have to use two nested Layouts, where the outer Layout casts the shadow with an elevation and the inner layout sets the background. Then by setting a padding to the outer Layout, we can shift the inner Layout … Read more
“android:elevation=” doesn’t work on devices pre-Lollipop with compile API21
UPDATED :: Best Practice to do that is <android.support.v7.widget.CardView> <YourLayout> </android.support.v7.widget.CardView> and add library for cardview dependencies { … compile ‘com.android.support:cardview-v7:21.0.+’ } On Pre-Lollipop you can use this drawable android:background=”@android:drawable/dialog_holo_light_frame” it will give you the look of elevation you can create your own like this <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <item> <shape android:shape=”rectangle”> <solid android:color=”#BDBDBD”/> … Read more
How to implement the Material-design Elevation for Pre-lollipop
You can mimic the elevation on pre-Lollipop with a official method. I achieve same effect using, android:background=”@android:drawable/dialog_holo_light_frame” My tested output: reference – https://stackoverflow.com/a/25683148/3879847 Thanks to user @Repo.. Update : If you want change color of this drawable try @Irfan answer below ↓ https://stackoverflow.com/a/40815944/3879847
Changing CardView shadow color
Consider this thread in twitter, where Nick Butcher talks about how to implement the feature: See outlineAmbientShadowColor, outlineSpotShadowColor, spotShadowAlpha and ambientShadowAlpha attributes for details. Unfortunately, that’s possible from API 28 onwards. For lower APIs Nick has shared a gist. Here’s the result: Running on API 21 This technique isn’t directly connected to CardView, it can … Read more
Remove elevation shadow without removing elevation itself
To complete M.Sandholtz answer, you can also define this in XML, with outlineProvider=”none”. <View android:id=”@+id/viewElevationNoShadow” android:outlineProvider=”none” android:elevation=”4dp” />