Android BottomNavigationView在左侧添加额外空间

Android BottomNavigationView在左侧添加额外空间,android,android-constraintlayout,android-styles,bottomnavigationview,Android,Android Constraintlayout,Android Styles,Bottomnavigationview,您好,我有一个BottomNavigationView,但它在开始处添加了一个默认空格。下面是我的代码 XML: 我已经参考了这篇文章,但没有帮助 我解决了这个问题,还尝试了app:itemBackground=“@android:color/holo\u green\u dark”,它也 没有解决我的间距问题 如果您不需要工具栏,它可以正常工作,您可以删除工具栏,或者如果您需要,请执行以下操作 <androidx.appcompat.widget.Toolbar an

您好,我有一个BottomNavigationView,但它在开始处添加了一个默认空格。下面是我的代码

XML:


我已经参考了这篇文章,但没有帮助 我解决了这个问题,还尝试了app:itemBackground=“@android:color/holo\u green\u dark”,它也
没有解决我的间距问题

如果您不需要工具栏,它可以正常工作,您可以删除工具栏,或者如果您需要,请执行以下操作

<androidx.appcompat.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:id="@+id/home_toolbar"
        app:contentInsetRight="0dp"
        app:contentInsetEnd="0dp"
        app:contentInsetStart="0dp"// this value which removes the space 
        app:contentInsetLeft="0dp"
        >

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/nav_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:itemBackground="@android:color/holo_green_dark"
            app:labelVisibilityMode="unlabeled"
            app:menu="@menu/pop_up" />

</androidx.appcompat.widget.Toolbar>

工具栏的默认设置是只有左插页还是所有边?
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
    android:id="@+id/navigation_home"
    android:icon="@drawable/home"
    android:title="@string/title_home"
    />

<item
    android:id="@+id/navigation_search"
    android:icon="@drawable/search"
    android:title="@string/title_dashboard" />

<item
    android:id="@+id/nav_add_post"
    android:icon="@drawable/add"
    android:title="@string/title_notifications" />

<item
    android:id="@+id/navigation_notifications"
    android:icon="@drawable/heart"
    android:title="@string/title_notifications" />

<item
    android:id="@+id/nav_profile"
    android:icon="@drawable/profile_icon"
    android:title="@string/title_notifications" />

</menu>
<androidx.appcompat.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:id="@+id/home_toolbar"
        app:contentInsetRight="0dp"
        app:contentInsetEnd="0dp"
        app:contentInsetStart="0dp"// this value which removes the space 
        app:contentInsetLeft="0dp"
        >

        <com.google.android.material.bottomnavigation.BottomNavigationView
            android:id="@+id/nav_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:itemBackground="@android:color/holo_green_dark"
            app:labelVisibilityMode="unlabeled"
            app:menu="@menu/pop_up" />

</androidx.appcompat.widget.Toolbar>