material-components-android: Problems with BottomAppBar Elevation
Version number
Library version: 1.0.0-alpha2
Details
While trying out the all-new BottomAppBar I’ve noticed that it has no elevation, which should be present by default as per the guidelines, and even worse than that is the fact there is no way to set it manually (.setElevation(…) & .setTranslationZ(…) have no effect).
I have also analyzed the source code of the aforementioned widget and it seems like the following should be responsible for the drawing of the background shadow:
topEdgeTreatment =
new BottomAppBarTopEdgeTreatment(fabCradleMargin, fabCornerRadius, fabVerticalOffset);
ShapePathModel appBarModel = new ShapePathModel();
appBarModel.setTopEdge(topEdgeTreatment);
materialShapeDrawable = new MaterialShapeDrawable(appBarModel);
materialShapeDrawable.setStrokeWidth(1f /* hairline */);
materialShapeDrawable.setShadowEnabled(true);
materialShapeDrawable.setPaintStyle(Style.FILL);
DrawableCompat.setTintList(materialShapeDrawable, backgroundTint);
ViewCompat.setBackground(this, materialShapeDrawable);
while it hints at its role in the drawing of the shadow, no shadow is actually getting drawn.
I believe this is a bug as the same widget is used in the Google I/O 2018 app, where it is displayed properly (with default elevation).
Screenshots
- My sample app

- Google I/O 2018 app

About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 7
- Comments: 23 (5 by maintainers)
My bad. I update the dependency
implementation ‘androidx.appcompat:appcompat:1.1.0-alpha01’ implementation ‘com.google.android.material:material:1.1.0-alpha02’
The shadow works fine now but when I set the fab to the end of bottomappbar the icons on the bottomappbar are also aligned at the end instead of the right side. It makes the icons and the fab collapsed at the end of bottomappbar
@davidlira94 still waiting for the stable release, which should have that issue addressed.
I have the same issue when using “com.android.support:design:28.0.0-alpha1”
I don’t know to enforce the elevation shadow, they brute-forced it or something or most probably they’re still using a drawable but now, setting
android:elevation="any value"inBottomAppBarin xml gives an NPE asI’ve also the latest support libraries :
I want to remove the elevation completely and setting the background null as below does nothing either.
Complete Log: