[英]set Image(PNG etc) as an icon on drawer layout navigation items
I'm setting the image as icon but its showing grey icon not the image, 我将图片设置为图标,但显示的是灰色图标而不是图片,
This @drawable/image_second
is the image I want to use as icon. 这个
@drawable/image_second
是我要用作图标的图像。
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_home"
android:icon="@drawable/image_second"
android:title="@string/menu_home" />
<item
android:id="@+id/nav_gallery"
android:icon="@drawable/ic_menu_gallery"
android:title="@string/menu_gallery" />
<item
android:id="@+id/nav_slideshow"
android:icon="@drawable/ic_menu_slideshow"
android:title="@string/menu_slideshow" />
<item
android:id="@+id/nav_tools"
android:icon="@drawable/ic_menu_manage"
android:title="@string/menu_tools" />
</group>
<item android:title="Communicate">
<menu>
<item
android:id="@+id/nav_share"
android:icon="@drawable/ic_menu_share"
android:title="@string/menu_share" />
<item
android:id="@+id/nav_send"
android:icon="@drawable/ic_menu_send"
android:title="@string/menu_send" />
</menu>
</item>
</menu>
after running the code,I get this, 运行代码后,我得到了,
please tell what to do and why its happening.. 请告诉该怎么办以及为什么会发生..
As always thanks a lot.. 一如既往的感谢。
尝试删除项目图标的色彩。
mNavigationView.setItemIconTintList(null);
You can do so programmatically using NavigationView.setItemIconTintList.
您可以使用NavigationView.setItemIconTintList以编程方式执行此操作。
yourNavigationView.setItemIconTintList(null);
Also If you want to change the tint of other icons use this 另外,如果您想更改其他图标的色彩,请使用此
In XML 在XML中
<android.support.design.widget.NavigationView
...
app:itemIconTint="@android:color/black"
... />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.