如何为“ BottomNavigationView”的菜单图标设置图像,因为它仅显示图像的设计,即结构...。

pra*_*_21 2 java android android-menu androiddesignsupport android-bottomnav

我想在BottomNavigationView菜单项中设置特定的图像,因为当我使用drawable设置图像时,它无法正常工作。

您还可以指导我如何显示活动的臀部...吗?

这是我的代码。

selectedActivity.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".selectedJokesActivity">

    <FrameLayout
        android:id="@+id/frame"
        android:layout_width="match_parent"
        android:layout_height="454dp">

    </FrameLayout>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginEnd="0dp"
        android:layout_marginStart="0dp"
        android:background="?android:attr/windowBackground"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:menu="@menu/navigation" />

</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

selectedActivity.xml

在此处输入图片说明

我的活动的屏幕截图:-

真实设备:Android Oreo

menu / navigation.xml:-

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

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

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

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

</menu>
Run Code Online (Sandbox Code Playgroud)

请帮忙....

Dev*_*ven 9

要获得图标图像的实际颜色或结构,请使用以下命令:

bottomNavigationView.setItemIconTintList(null);
Run Code Online (Sandbox Code Playgroud)