Description:
When the app:elevation is used with the AppBarLayout the elevation is not set
The following is not working:
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="8dp">
The elevation appears though when the android namespace is used:
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="8dp">
Expected behavior:
I would expect the app:elevation to work the same as android:elevation.
Source code:
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="8dp">
Android API version: Tested on Android 9 (API 28)
Material Library version:
1.1.0-beta02
Device:
Samsung A20
I have also faced the same problem.
This is WAI. Why do you need to use app:elevation? Elevation is supported only for L+ and android:elevation will be ignored on pre-L devices.
Hmm, I disagree it's working as intended. First of all the app:elevation property is there. There is also code around it, that tries to set the elevation - it doesn't work.
I've just done quick research about that and found this https://github.com/material-components/material-components-android/issues/652, which is also an indication that something is wrong here.
My point here is, there is no clear documentation around app:elevation and android:elevation. I had to spend some time investigating why there is no elevation there. Wanted to highlight this to people working on the library and maybe make someone else's life easier in the future.
In my situation elevation doesn't work well because I haven't given any background to the toolbar. Try giving color to the toolbar then set elevation and it will work well.
Most helpful comment
Hmm, I disagree it's working as intended. First of all the
app:elevationproperty is there. There is also code around it, that tries to set the elevation - it doesn't work.I've just done quick research about that and found this https://github.com/material-components/material-components-android/issues/652, which is also an indication that something is wrong here.
My point here is, there is no clear documentation around
app:elevationandandroid:elevation. I had to spend some time investigating why there is no elevation there. Wanted to highlight this to people working on the library and maybe make someone else's life easier in the future.