當您單擊我的導航抽屜中的菜單項時,它會變得稍暗並保持這種狀態,直到單擊另一個項目。我試圖讓它保持相同的顏色,不管它處於什麼狀態。Android刪除導航菜單項突出
它是否是某種疊加?我想我已經在drawer_items.xml中覆蓋了所有可能的狀態。
如何防止此行爲?
activity_main.xml中
<android.support.design.widget.NavigationView
.
.
android:background="@drawable/drawer_items"
.
app:menu="@menu/activity_main_drawer" />
drawer_items.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/grey" android:state_activated="true" />
<item android:drawable="@color/grey" android:state_selected="true" />
<item android:drawable="@color/grey" android:state_focused="true" />
<item android:drawable="@color/grey" android:state_pressed="true" />
<item android:drawable="@color/grey" android:state_checked="true" />
<item android:drawable="@color/grey" />
</selector>
activity_main_drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single"
android:id="@+id/arbitrary_id_1">
<item
android:id="@+id/nav_refresh"
android:icon="@drawable/ic_refresh_24dp"
android:title="Try Again/Refresh" />
</group>
<group android:checkableBehavior="single"
android:id="@+id/arbitrary_id_2">
<item
android:id="@+id/nav_back"
android:icon="@drawable/ic_fast_rewind_24dp"
android:title="Go Back" />
</group>
<group android:checkableBehavior="single"
android:id="@+id/arbitrary_id_3">
<item
android:id="@+id/nav_3" />
</group>
</menu>
發表您的'activity_main_drawer' – tachyonflux
也許您的問題來源於代碼的活動,而不是從XML,你可以發佈您的代碼? – JJ86