更改底部导航视图的图标大小但图标覆盖文本?

change the icon size of the bottom-navigation view but the icon covers text?

我更改了图标大小,但它与文本重叠

我已经增加了 bottomView 的高度,但仍然如此。

只有边(边距?)改变了。

我已经搜索并找到了

的答案
<dimen name="design_bottom_navigation_height" tools:override="true">56dp</dimen>

但我创建了 xml 并编写了它,但是没有工具命名空间?

底部导航视图中有一个 属性 app:itemIconSize="@dimen/_26sdp",您可以在其中增大或减小图标大小。


它对我有用。希望它也对你有用。祝你有个愉快的一天伙计:) .


更新

图标填充在 BottomNavigationView 中是不可能的你必须需要图标填充然后你可以像下面给出的那样设置你的 xml 文件。

test.xml

<RelativeLayout 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.bottomnavigation.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/white">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:orientation="horizontal"
            android:weightSum="5">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:drawablePadding="10dp"
                android:gravity="center"
                android:padding="10dp"
                android:text="ABC"
                app:drawableTopCompat="@drawable/ic_chat_bubble_orange_24dp" />

            <TextView
                android:id="@+id/test_2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:drawablePadding="10dp"
                android:gravity="center"
                android:padding="10dp"
                android:text="DEF"
                app:drawableTopCompat="@drawable/ic_chat_bubble_orange_24dp" />

            <TextView
                android:id="@+id/test_3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:drawablePadding="10dp"
                android:gravity="center"
                android:padding="10dp"
                android:text="DEF"
                app:drawableTopCompat="@drawable/ic_chat_bubble_orange_24dp" />

            <TextView
                android:id="@+id/test_4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:drawablePadding="10dp"
                android:gravity="center"
                android:padding="10dp"
                android:text="DEF"
                app:drawableTopCompat="@drawable/ic_chat_bubble_orange_24dp" />

            <TextView
                android:id="@+id/test_5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:drawablePadding="10dp"
                android:gravity="center"
                android:padding="10dp"
                android:text="DEF"
                app:drawableTopCompat="@drawable/ic_chat_bubble_orange_24dp" />

        </LinearLayout>

    </com.google.android.material.bottomnavigation.BottomNavigationView>

</RelativeLayout>

您的设计将如下图所示。


屏幕截图