androidxmlandroid-studionavigationbar

How to Remove Background of BottomNavigationView Item in Android?


I'm working on an Android application and I'm trying to remove the background from a BottomNavigationView. Currently, it displays a purple (like a button) background, but I would like it to be transparent (or shadowed). Below is a screenshot of my current navigation bar:

enter image description here

Here is the XML code for the BottomNavigationView:

<com.google.android.material.bottomnavigation.BottomNavigationView
    android:id="@id/bottom_navigation"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    app:itemIconSize="32dp"
    app:itemIconTint="#263238"
    app:itemTextColor="@color/bottom_nav_text_color"
    app:labelVisibilityMode="unlabeled"
    app:layout_constraintBottom_toBottomOf="parent"
    app:menu="@menu/bottom_navigation_menu"
/>

And here is the menu XML:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/navigation_saved"
        android:icon="@drawable/outline_article_24"
        android:title="@string/saved_lists"
    />
    <item
        android:id="@+id/navigation_home"
        android:icon="@drawable/baseline_home_24"
        android:title="@string/home"
    />
    <item
        android:id="@+id/navigation_add"
        android:icon="@drawable/baseline_add_chart_24"
        android:title="@string/add"
    />
</menu>

How can I make the background of the BottomNavigationView Item transparent?


Solution

  • In my case, I had to change the theme.xml accordingly:

       <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
           
            <item name="colorAccent">@color/white</item>
    

    The theme style was used in style.xml and I need to delete it there and use it only in the theme