Wie man die navigation Schublade unterhalb der Symbolleiste?
Hier meine navigation Schublade ist oben die Symbolleiste.Ich habe auch einige xml-code.Bitte helfen Sie mir.
hier ist meine activity.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_categories"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/activity_main2_drawer" />
</android.support.v4.widget.DrawerLayout>
und meine app_bar xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.ezybzy.ezybzy.categoris">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_categoris" />
</android.support.design.widget.CoordinatorLayout>
und meine Inhalte main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.ezybzy.ezybzy.categoris"
tools:showIn="@layout/app_bar_categories"
android:background="#ffffff">
</RelativeLayout>
Habe ich die navigation Schublade mit android studios navigation drawer activity..
- Kann ich sehen, Ihre xml?
- Sie können sich auf dieser post - stackoverflow.com/questions/31059761/...
- besuchen Sie diese Website, Es wird Ihnen helfen, um code androidhive.info/2013/11/...
InformationsquelleAutor Kiran Benny Joseph | 2016-03-05
Schreibe einen Kommentar Antworten abbrechen
Du musst angemeldet sein, um einen Kommentar abzugeben.
sicherlich
android:layout_marginTop="?attr/actionBarSize"
den job inAber das problem ist drawerlayout ist oben in der Symbolleiste. Das ist, warum die verblassen hier.
Sie können entfernen Sie verblassen
Aber auf einigen Geräten kann es Aussehen WLAN.
Lösung
Beim arbeiten mit Android studio. Wir erstellen
NavigationDrawerActiviity
Es gibt 3 Dateien mit den Namen
So können wir überspringen
app_bar_main.xml
und wir können entfernen Sie die verblassen.Schritt 1
Machen, der root-Ansicht der Aktivität hauptsächlich als Vertikale
LinearLayout
In
activity_main.xml
hinzufügenDrawerLayout
und gehörencontent_main.xml
imDrawerLayout
. und Fügen SieAppBarLayout
über dieDrawerLayout
.Schritt 2
hinzufügen und ersetzen
setContentView()
von NavigationDrawerActiviity zuSchließlich haben wir
Hinzufügen
Ihrem layout, die Sie verwenden, wie Schublade.
In Ihrem Navigations Schublade xml-sollten Sie
android:layout_marginTop ="?android:attr/actionBarSize"
auf den container.Wenn Sie benutzerdefinierte Symbolleiste, dann verwenden Sie die-Schublade-layout in dieser Art und Weise..
und wenn Sie nicht mit benutzerdefinierten Symbolleiste, dann müssen Sie noch festlegen, Rand oben an der Schublade layout..
Erstellen Sie ein layout wie diese:
Ihre Schublade für Ihre Symbolleiste zu vermeiden, versuchen Sie folgenden code
Eine Einfache und Gute Lösung
fitsSystemWindows=false
fürdass hat id als
Und für
navigationView
setlayout_marginTop
als?attr/actionBarSize
dass die actionbar Größe und legen Sie es als MargeHier ist komplett
activity_main.xml
code, der beide oben aufgeführten änderungen.mDrawerLayout.setScrimColor(ContextCompat.getColor(getApplicationContext(), android.R.color.transparent));
verwenden können, ändern Sie den navigation drawer xml
android:layout_marginTop ="0dp"
legen Sie den oberen Rand in der Symbolleiste