Geetika Sachdeva:
layout_gravity属性は、「スタート」= layout_gravityを与えたいナビゲーションView.Iに表示されていないが、それは表示されません。
ここに私のlayout.xmlファイルがあります
<androidx.drawerlayout.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:context=".HomeActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="@dimen/_4sdp"
android:background="@color/colorPrimary">
</androidx.appcompat.widget.Toolbar>
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"/>
ガブリエル14:
あなたのナビゲーションビューを見たい場合は、追加する必要がありますtools:openDrawer:"start"
にDrawerLayout
。これは、ユーザーがそれを開くまでのアプリでそれが表示されません、唯一のレイアウトエディタに見えるよう、あなたの引き出しを設定します。
(使用している場合)と重力、メニューやヘッダーのレイアウトを設定することも忘れないでください
android:layout_gravity="start"
app:menu="@menu/your_menu"
app:headerLayout="@layout/your_header_layout"
あなたのNavigationViewインチ
それが役に立てば幸い!