Как изменить цвет элементов нижней панели приложения?

У меня есть BottomAppBar с FAB из нового Material Design. У этого BottomAppBar есть специальное меню, которое содержит 2 пункта плюс один значок навигации. Проблема в том, что я установил белый цвет нижней панели приложения, и значки тоже белые. Как я могу это изменить? Это мой activity_layout

<androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.google.android.material.bottomappbar.BottomAppBar
            android:id="@+id/bottomAppBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            app:hideOnScroll="true"
            style="@style/BottomAppBarTheme"
            app:menu="@menu/bottom_app_bar"
            app:navigationIcon="@drawable/ic_menu_black_24"
            app:fabCradleMargin="10dp" />

        <com.google.android.material.floatingactionbutton.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:srcCompat="@drawable/ic_add_white_24"
            app:layout_anchor="@id/bottomAppBar"
            app:shapeAppearance="@style/FabDiamondOverlay"

            />
    </androidx.coordinatorlayout.widget.CoordinatorLayout>

А это мой styles.xml

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/primaryColor</item>
        <item name="colorPrimaryDark">@color/primaryDarkColor</item>
        <item name="colorAccent">@color/secondaryColor</item>
        <item name="android:actionMenuTextColor">@android:color/black</item>

    </style>

    <style name="FabDiamondOverlay" parent="">
        <item name="cornerFamily">cut</item>
        <item name="cornerSize">8dp</item>
    </style>

    <style name="BottomAppBarTheme" parent="Widget.MaterialComponents.BottomAppBar.Colored">
        <item name="android:itemBackground">@android:color/black</item>
    </style>

Вот изображение нижней панели приложения (с белыми значками ...):  введите описание изображения здесь


person André Nogueira    schedule 10.07.2020    source источник


Ответы (1)


Ты можешь использовать:

<com.google.android.material.bottomappbar.BottomAppBar
    android:theme="@style/BottomAppBarOverlay"
     .../>

с участием:

<style name="BottomAppBarOverlay">
    <item name="colorControlNormal">@color/...</item>
</style>

введите описание изображения здесь

Вы также можете использовать:

<com.google.android.material.bottomappbar.BottomAppBar
    style="@style/MyBottomAppBar"
    ..>

с участием:

<style name="MyBottomAppBar" parent="Widget.MaterialComponents.BottomAppBar">
    <item name="materialThemeOverlay">@style/ThemeOverlay.BottomAppBar</item>
</style>

<style name="ThemeOverlay.BottomAppBar" parent="ThemeOverlay.MaterialComponents.BottomAppBar.Primary">
    <item name="colorOnPrimary">@color/.....</item>
</style>
person Gabriele Mariotti    schedule 10.07.2020
comment
Вот и все! Спасибо! - person André Nogueira; 11.07.2020