【问题标题】:Can not use colored icons for Slide Drawer不能为滑动抽屉使用彩色图标
【发布时间】:2017-08-20 14:17:22
【问题描述】:

我在这里使用的图标都是彩色的,但在运行时不会显示。 我在 xml 中尝试了 app:itemIconTint="@null",但没有用。

XML CODE:
<?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/home"
        android:title="@string/home"
        android:icon="@drawable/icon_home"
        app:itemIconTint="@null"/>

    <item android:id="@+id/help"
        android:title="@string/help"
        android:icon="@drawable/icon_help"/>
</menu>

**这是另一个布局文件,幻灯片抽屉将出现。我删除了不必要的代码以使其变得简单**

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
             ........../>

    </LinearLayout>

    <android.support.v4.widget.DrawerLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.NavigationView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:menu="@menu/navigation"
            android:layout_gravity="start">

        </android.support.design.widget.NavigationView>

    </android.support.v4.widget.DrawerLayout>
</RelativeLayout>

【问题讨论】:

  • 你在使用 NavigationView @ Aryan 吗?
  • 是的,我正在使用导航视图,我也在添加 XML 代码。
  • 将此添加到您的活动@Aryan

标签: android xml material-design


【解决方案1】:

将此添加到您的活动中

navi_view.setItemIconTintList(null);

navi_view 是 NavigationView 的对象。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-12
    • 1970-01-01
    • 2013-09-07
    • 1970-01-01
    • 2018-12-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多