繁体   English   中英

在底部导航栏看不到任何图标

[英]Unable to see any icons at the Bottom Navigation bar

我一直在尝试在底部导航栏上显示图标图像。 无论我尝试什么,我仍然无法得到它。 我一直在尝试很多不同的方法来解决但无济于事。 有人可以帮我吗? 也许我错过了什么。

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/yellow"
    tools:context=".MainActivity">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:id="@+id/fragment_layout">
    </FrameLayout>


    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavView"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_gravity="bottom"
        android:background="@color/white"
        app:menu="@menu/menu">

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

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




    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android">

<item
    android:id="@+id/nav_donate"
    android:icon="@drawable/donate_icon"
    android:title="Donate"/>

<item
    android:id="@+id/nav_status"
    android:icon="@drawable/status_icon"
    android:title="Status"/>

<item
    android:id="@+id/nav_history"
    android:icon="@drawable/history_icon"
    android:title="History"/>

<item
    android:id="@+id/nav_logout"
    android:icon="@drawable/logout_icon"
    android:title="Log Out"/>
    </menu>
    ```

下面的图片链接是目前的显示方式。 [1]: https://i.stack.imgur.com/EH6AQ.png

您的布局高度设置为 0dp android:layout_height="0dp"它与给定的约束相匹配。 我没有看到您的显示,但我猜框架布局隐藏了您的 bottomNavView。 改成

<FrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:id="@+id/fragment_layout"
        app:layout_constraintTop_toTopOf="parent">
        app:layout_constraintBottom_toTopOf="@id/bottomNavView">
    </FrameLayout>

 <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavView"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_gravity="bottom"
        android:background="@color/white"
        app:layout_constraintBottom_toBottomOf="parent">
        app:menu="@menu/menu"/>

@Niaj Mahmud 的帮助下进行编辑。

将您应用级别 build.gradle 文件中的材料版本从 1.5.0 更改为 1.3.0

是的,在物理设备中它工作正常但在预览中它不显示。 此问题适用于材料版本 1.5.0.. 尝试设计视图中底部导航的材料 1.3.0 版本实时视图不显示图标和菜单资源

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM