Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove elevation shadow without removing elevation itself

Is there a way for AppBarLayout to no drop shadow and keep its elevation?

<android.support.design.widget.AppBarLayout         app:elevation="0dp"> 
like image 308
Jocky Doe Avatar asked Dec 09 '17 12:12

Jocky Doe


People also ask

How do you remove shadow from card in flutter?

You can use shadowColor : Colors. transparent for it.

How do I get rid of shadows on Android?

If you want an Android app to remove shadow from photo, you can use Remove Unwanted Content. Just like other apps, this app offers two selection tools including the lasso and brush tools which allows you to select the shadow areas from your image.

What is shadow elevation?

Elevation helps users understand the relative importance of each element and focus their attention to the task at hand. The elevation of a view, represented by the Z property, determines the visual appearance of its shadow: views with higher Z values cast larger, softer shadows.


2 Answers

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"/> 
like image 85
Sean Blahovici Avatar answered Oct 03 '22 03:10

Sean Blahovici


I just ran into this same problem and this is what fixed it for me:

val withElevationNoShadow = view.findViewById<*your view type*>(*your view id*) withElevationNoShadow.outlineProvider = null 

Keep in mind that the code above is Kotlin, but the Java is almost identical.

This works because shadows are drawn by ViewOutlineProviders. By setting your view's ViewOutlineProvider to null, you take away the default shadow.

For more info about ViewOutlineProviders check out

https://developer.android.com/reference/android/view/ViewOutlineProvider

and

https://developer.android.com/training/material/shadows-clipping

like image 39
Clark Sandholtz Avatar answered Oct 03 '22 03:10

Clark Sandholtz