Ich versuche NavigationView zu verwenden, um NavigationDrawer zu implementieren. Ich habe das Trennzeichen hinzugefügt, indem ich Gruppen-ID im Menü gesetzt habe. Allerdings kann ich das Trennzeichen nicht sehen. Ich schätze, das liegt daran, dass die Farbe des Separators gleich dem Hintergrund ist. Also ich möchte die Trennfarbe ändern. Aber ich finde keine Möglichkeit, es zu ändern. Kann mir jemand helfen?Wie kann ich die Separatorfarbe in NavigationView ändern?
In Screenshot scheint es einen Raum für Trennzeichen zwischen History
und Settings
zu haben, aber Sie können es nicht sehen.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:context=".ui.MapActivity">
<LinearLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar_actionbar" />
<!--main content-->
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/navdrawer_background"
app:insetForeground="#4000"
app:itemTextColor="@color/navdrawer_item_text_color"
app:itemIconTint="@color/navdrawer_item_icon_tint"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/drawer"/>
</android.support.v4.widget.DrawerLayout>
drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/group_feature"
android:checkableBehavior="single">
<item android:id="@+id/navdrawer_item_map"
android:checked="true"
android:icon="@drawable/ic_drawer_map"
android:title="@string/navdrawer_item_map"/>
<item android:id="@+id/navdrawer_item_favourite"
android:icon="@drawable/ic_drawer_fav"
android:title="@string/navdrawer_item_fav"/>
<item android:id="@+id/navdrawer_item_history"
android:icon="@drawable/ic_drawer_history"
android:title="@string/navdrawer_item_history"/>
</group>
<group android:id="@+id/group_settings"
android:checkableBehavior="single">
<item android:id="@+id/navdrawer_item_settings"
android:icon="@drawable/ic_drawer_settings"
android:title="@string/navdrawer_item_settings"/>
<item android:id="@+id/navdrawer_item_help"
android:icon="@drawable/ic_drawer_help"
android:title="@string/navdrawer_item_help"/>
<item android:id="@+id/navdrawer_item_about"
android:icon="@drawable/ic_drawer_about"
android:title="@string/navdrawer_item_about"/>
</group>
</menu>
Jeder Weg, es programmatisch zu tun? – ElYeante
@ElYeante Nein leider gibt es keine Möglichkeit, es programmatisch zu machen ... vielleicht wird es in Zukunft eine Bibliothek geben .. – Moinkhan
Funktioniert super! Danke – Vinayak