自定义NavDrawer中项目的突出显示颜色

时间:2018-07-24 21:18:34

标签: android android-layout android-studio navigation-drawer

我正在寻找一种自定义导航抽屉中项目突出显示颜色的方法,如上图“收件箱”项目中的图片。

我想更改高光印刷机颜色的高度和边缘..

我该怎么做?

非常感谢。

enter image description here

1 个答案:

答案 0 :(得分:0)

在抽屉里面的物品_item.xml做类似的事情

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="checked state color" android:state_checked="true" />
<item android:color="your default color" />
</selector>

更改您的NavigationView

<android.support.design.widget.NavigationView
android:id="@+id/activity_main_navigationview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/drawer_header"
app:itemIconTint="@color/drawer_item"  // notice here
app:itemTextColor="@color/drawer_item" // and here
app:itemBackground="@android:color/transparent"// and here for setting the background 
color to tranparent
app:menu="@menu/menu_drawer">