1
ナビゲーションビューを追加しようとしていますが、ツールバーの下に表示されています。その結果、最初の項目は表示されず、閉じた状態のナビゲーションビューも表示されない上3つの水平線も表示されません。 アンドロイドのツールバーの下にあるナビゲーションビュー
コード:
<?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_main"
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:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
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">
<item
android:id="@+id/nav_home"
android:icon="@drawable/ic_action_home"
android:title="Home" />
<item
android:id="@+id/nav_profile"
android:icon="@drawable/ic_action_profile"
android:title="My Profile" />
<item
android:id="@+id/nav_history"
android:icon="@drawable/ic_action_history"
android:title="History" />
<item
android:id="@+id/nav_payment"
android:icon="@drawable/ic_action_payment"
android:title="Payment Methods" />
<item
android:id="@+id/nav_contact"
android:icon="@drawable/ic_action_contact"
android:title="Contact" />
<item
android:id="@+id/nav_about"
android:icon="@drawable/ic_action_about"
android:title="About" />
<item
android:id="@+id/nav_logout"
android:icon="@drawable/ic_action_log_out"
android:title="Logout" />
</group>
</menu>
nav_header_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Vitalia"
android:id="@+id/navHeaderTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.constraint.ConstraintLayout>
しようとしたソリューション:
ナビゲーションビューにandroid:layout_marginTop="@dimen/abc_action_bar_default_height_material"
を追加しようとしましたが、結果は()
となります。
あなたapp_bar_main.xmlのレイアウトコードを試してみてください。 –
android:fitsSystemWindows = "true"これはapp_bar_main.xmlレイアウトにのみ渡されます。 –
@AnkushBist app_bar_main.xmlを削除する場合も同じ問題が存在します。 –