material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[BottomAppBar] BottomAppBar casts a shadow

Open manabu-nakamura opened this issue 2 years ago • 5 comments

https://github.com/material-components/material-components-android/issues/2698...

Description: BottomAppBar (https://m3.material.io/components/bottom-app-bar/overview):

  • Elevation: No shadow
  • M3: Bottom app bar has new colors, a taller container, no elevation or shadow, and contains the FAB.

unnamed9 But, the BottomAppBar casts a shadow (https://github.com/material-components/material-components-android/issues/2852). 180359724-25751a28-3757-45b5-8b06-88ac6bb92b48 The MaterialToolbar casts no drop shadow (https://github.com/material-components/material-components-android/issues/2698#issuecomment-1233742799). https://m3.material.io/components/top-app-bar/overview https://github.com/material-components/material-components/issues/108

Expected behavior: The BottomAppBar casts no shadow. Or revise the documentation.

Source code:

<androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:layout_gravity="bottom" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

Minimal sample app repro: Test1.zip (https://github.com/material-components/material-components-android/issues/2852)

Android API version: 33

Material Library version: 1.7.0-rc01

Device: Emulator 31.3.10

manabu-nakamura avatar Sep 02 '22 02:09 manabu-nakamura

I feel that's intended. @imhappi can you confirm this with the designers?

drchen avatar Sep 02 '22 15:09 drchen

I want a document like https://material.io/design/environment/elevation.html.

manabu-nakamura avatar Sep 08 '22 05:09 manabu-nakamura

I think @manabu-nakamura is right, the M3 guideline clearly says the redesigned M3 BottomAppBar doesn't have any elevation shadow (like the M3 top app bar, it also has no shadow), only the Surface Level 2 elevation tint. In order to remove the shadow, I currently have to set app:elevation="0dp" on the BottomAppBar and then programmatically

binding.bottomAppBar.setBackgroundColor(SurfaceColors.SURFACE_2.getColor(context));

to get the correct elevation tint without any shadow.

patzly avatar Sep 15 '22 10:09 patzly

Thank you, @patzly. This method can also be used for the navigation bar (BottomNavigationView). https://m3.material.io/components/navigation-bar/overview

My method can not be used for the navigation bar:

((MaterialShapeDrawable)binding.appBar.getBackground()).setShadowCompatibilityMode(MaterialShapeDrawable.SHADOW_COMPAT_MODE_NEVER);

https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/bottomappbar/BottomAppBar.java#L355:

materialShapeDrawable.setShadowCompatibilityMode(SHADOW_COMPAT_MODE_ALWAYS);

manabu-nakamura avatar Sep 16 '22 07:09 manabu-nakamura

Hi! Sorry, I was out last week

Yes, the designer has confirmed that although there is elevation, there should be no shadow. Changes for this will go out soon

imhappi avatar Sep 19 '22 16:09 imhappi