Skip to content

[BottomAppBar] children are not laid out correctly #2852

@manabu-nakamura

Description

@manabu-nakamura

Description: The children of BottomAppBar are not laid out correctly when app:menuAlignmentMode is start (The children of BottomAppBar are laid out correctly when app:menuAlignmentMode is auto).
397e48f
Screenshot_20220722_125942

Expected behavior: The children of BottomAppBar are laid out correctly when app:menuAlignmentMode is start.
Screenshot_20220720_142926

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:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:layout_gravity="bottom"
        android:layout_marginBottom="?actionBarSize"
        app:menu="@menu/main"
        app:menuAlignmentMode="auto">
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/auto" />
    </com.google.android.material.bottomappbar.BottomAppBar>
    <com.google.android.material.bottomappbar.BottomAppBar
        android:id="@+id/appBar"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:layout_gravity="bottom">
<!--        android:paddingEnd="-40dp"
        app:contentInsetStart="44dp"-->
<!--        app:menuAlignmentMode="start"-->
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/start" />
    </com.google.android.material.bottomappbar.BottomAppBar>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

The default value of app:menuAlignmentMode (Widget.Material3.BottomAppBar) is not auto but start.
https://m3.material.io/components/bottom-app-bar/implementation:

Element        | Attribute             | Related method(s)    | Default value
Alignment mode | app:menuAlignmentMode | setMenuAlignmentMode | auto
               |                       | getMenuAlignmentMode |

https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/bottomappbar/res/values/styles.xml#L64
https://github.com/material-components/material-components-android/blob/master/docs/components/BottomAppBar.md
397e48f

276a0a3

Minimal sample app repro: Test1.zip

Android API version: 32

Material Library version: 1.7.0-alpha03

Device: Emulator 31.2.10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions