Solution 1 :
As you can find in the doc:
in a dark theme the elevation overlays are semi-transparent white
(colorOnSurface
) overlays that are conceptually placed on top of the
surface color.
It is managed by the library.
Just an example with a MaterialCardView
with app:cardElevation="4dp"
and app:cardElevation="8dp"
.
Light mode:
Dark mode:
The overlay is based on the colorOnSurface
defined in the app theme.
You can change this color adding in the app theme:
<item name="elevationOverlayColor">@color/...</item>
You can also disable this behavior using in the app theme:
<item name="elevationOverlayEnabled">false</item>
Many components in the Material Components Library support elevation overlays in dark theme but you can also apply it in your custom view using using the MaterialShapeDrawable
.
For example you can use a LinearLayout
:
LinearLayout linearLayout1= findViewById(R.id....);
MaterialShapeDrawable shapeDrawableLL1 =
MaterialShapeDrawable.createWithElevationOverlay(this, 4.0f );
ViewCompat.setBackground(linearLayout1,shapeDrawableLL1);
LinearLayout linearLayout2= findViewById(R.id....);
MaterialShapeDrawable shapeDrawableLL2 =
MaterialShapeDrawable.createWithElevationOverlay(this, 16.0f );
ViewCompat.setBackground(linearLayout2,shapeDrawableLL2);
Problem :
I came across elevation overlay several times. Even though I read some definitions, I seem not to find exact meaning of it. Can you help me with that? What is it? How is it used?
Here is the link
Comments
Comment posted by material.io/develop/android/theming/dark
“I came across elevation overlay several times” — can you edit your question and provide links to the places that are using this term? Are you referring to
Comment posted by material.io/design/environment/…
detailed here
Comment posted by Khamidjon Khamidov
Thanks for your comment CommonsWare. I edited it
Comment posted by Khamidjon Khamidov
Thank you Yunus for the link, but I can’t see a lot of use of it;(. I want to know how it is used(in what circumstances)
Comment posted by Khamidjon Khamidov
Thank you very much for your answer. I have understood much better now
Comment posted by Izak
Thanks. I thought I can set