Android 导航抽屉问题操作栏隐藏,导航项单击不起作用,图像项背景已更改
我创建了带有导航抽屉的幻灯片菜单,操作栏隐藏在主活动上,项目不可单击,导航项目图像不正确可见。附加图片和代码如下 这就是它的样子 应该如何(在iOS中) 在main_activity.xml中添加导航Android 导航抽屉问题操作栏隐藏,导航项单击不起作用,图像项背景已更改,android,navigation-drawer,Android,Navigation Drawer,我创建了带有导航抽屉的幻灯片菜单,操作栏隐藏在主活动上,项目不可单击,导航项目图像不正确可见。附加图片和代码如下 这就是它的样子 应该如何(在iOS中) 在main_activity.xml中添加导航 <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawer_layout"
android:fitsSystemWindows="true"
android:background="?attr/colorButtonNormal"
tools:context=".MainActivity"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:id="@+id/toolbar"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="4dp"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/fragment_container"/>
</LinearLayout>
<android.support.design.widget.NavigationView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:id="@+id/nav_view"
app:headerLayout="@layout/nav_header"
app:itemTextColor="@color/viewBgr"
app:menu="@menu/drawer_menu"
/>
在同一类中添加的操作查找以下方法
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem)
试试这个:
<?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.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="true"
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="@color/white"
app:popupTheme="@style/AppTheme.PopupOverlay">
.....
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start">
<include
layout="@layout/app_bar_dashboard" // APP_BAR
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"
app:headerLayout="@layout/nav_header_dashboard"
app:itemIconTint="@drawable/drawer_item"
app:itemTextColor="@drawable/drawer_item"
app:menu="@menu/activity_dashboard_drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
.....
根据这个xml,您还必须更改java类
如果这将不起作用,请让我在评论中知道
编辑:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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="ai.gramboard.app.activity.DashboardActivity">
<include layout="@layout/content_dashboard"/> //include here content xml
</FrameLayout>
应用程序工具栏仪表板:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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="ai.gramboard.app.activity.DashboardActivity">
<include layout="@layout/content_dashboard"/> //include here content xml
</FrameLayout>
//在此处包含内容xml
app\u bar\u仪表板中有什么,抽屉项目和活动\u仪表板\u抽屉获取错误。请你详细说明一下我是新来的,这很难理解,好吗elaborate@OhStack第一个xml属于导航活动,第二个属于app barWorking,但操作栏隐藏。您可以像这样检查顶部的第一个图像
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem)
<?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.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="true"
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="@color/white"
app:popupTheme="@style/AppTheme.PopupOverlay">
.....
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:openDrawer="start">
<include
layout="@layout/app_bar_dashboard" // APP_BAR
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"
app:headerLayout="@layout/nav_header_dashboard"
app:itemIconTint="@drawable/drawer_item"
app:itemTextColor="@drawable/drawer_item"
app:menu="@menu/activity_dashboard_drawer" />
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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="ai.gramboard.app.activity.DashboardActivity">
<include layout="@layout/content_dashboard"/> //include here content xml
</FrameLayout>