[英]Navigation Drawer icon is missing
I can only swipe to open navigation drawer as my navigation drawer button is missing.由于缺少导航抽屉按钮,我只能滑动以打开导航抽屉。 I am using drawer layout for the nav view and co- ordinator layout for the bottom bar menu.我为导航视图使用抽屉布局,为底部栏菜单使用协调器布局。
The code for the main activity:主要活动的代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/dl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/baseLayout"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/default_activity_button"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="top"
android:backgroundTint="@color/buttoncolor"
app:menu="@menu/default_menu" />
<!--status bar-->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:backgroundTint="@color/buttoncolor"
app:fabAlignmentMode="end"
app:fabCradleMargin="6.2sp"
app:fabCradleRoundedCornerRadius="15sp"
app:menu="@menu/app_bar_menu" />
<!--add button-->
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:backgroundTint="#ED4444"
android:onClick="openCamera"
android:src="@drawable/ic_add"
app:layout_anchor="@id/bottomAppBar"
app:maxImageSize="35sp"
app:tint="@color/white" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<RelativeLayout
android:layout_marginTop="50dp"
android:layout_marginBottom="50dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rw"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/empty_list" />
<LinearLayout
android:id="@+id/empty_list"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical">
<ImageView
android:id="@+id/empty_list_icon"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="@drawable/ic_no_data" />
<TextView
android:id="@+id/empty_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Scan the files"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textSize="24dp"
android:gravity="center_horizontal"/>
<TextView
android:id="@+id/empty_list_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Scan to make something great"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:gravity="center_horizontal" />
</LinearLayout>
</RelativeLayout>
<com.google.android.material.navigation.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:menu="@menu/navigation_menu"
android:layout_gravity="start"
app:headerLayout="@layout/navigation_header"
android:id="@+id/nav_view"/>
</androidx.drawerlayout.widget.DrawerLayout>
I think overlay BottomAppBar "default_activity_button" please remove and check我认为覆盖BottomAppBar“default_activity_button”请删除并检查
set navigation icon
set attributes **app:navigationIcon**
OR或者
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.ic_good);
toolbar.setTitle("Title");
toolbar.setSubtitle("Sub");
toolbar.setLogo(R.drawable.ic_launcher);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.