Ich muss der Kopfzeile meiner Navigationsleiste Aktionsschaltfläche hinzufügen. Aber dafür kann ich keine gute Lösung finden. Ich brauche dieses Ergebnis in meiner app zu erreichen:So fügen Sie dem Material NavigationDrawer-Header eine Aktionsschaltfläche hinzu
Wenn Sie die Schaltfläche geklickt Sie etwas sehen sollte:
Unfortunatelly ich weiß nicht, wie soll ich diese Schaltfläche hinzufügen zu meinem XML. Dies ist der komplette Kopf .xml für meine Schublade:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="280dp"
android:layout_height="240dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/drawer_header_layout"
android:layout_width="280dp"
android:layout_height="168dp"
android:background="@drawable/placeholder"
android:gravity="bottom"
android:orientation="vertical"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="@+id/drawer_header_image"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="43dp"
android:contentDescription="null"
android:scaleType="centerCrop"
tools:src="@drawable/avatar_circle" />
<TextView
android:id="@+id/drawer_header_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="@color/bodyTextColor"
android:textStyle="bold"
tools:text="Elizabeth Cray" />
<TextView
android:id="@+id/drawer_header_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="9dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
tools:text="[email protected]"
/>
</LinearLayout>
Gibt es jemanden, der weiß, wie man leicht auf diese Schaltfläche hinzufügen?
Dank
Sie sollten fähig sein: Sie diese XML in Ihre res-Haupt
Und Sie sollten dies nennen in MainActivity wie sollte hinzufügen um ein weiteres ImageView mit dem Überlaufsymbol hinzuzufügen. Allerdings habe ich dieses UX-Muster noch nie in einer App gesehen. In der Regel fügen Sie nach einem gewissen Abstand innerhalb der Liste der NavigationView eine weitere Aktion hinzu. –
Ich denke, dass ein ImageButton mit diesem Symbol als Quelle im Layout platziert ist, das als Überschrift der Navigation verwendet wurde. – Aiapaec