如何在使用导航抽屉的片段时在底部导航栏上添加导航抽屉?
问题描述:
活动由底部导航栏和片段组成。该片段包含一个导航抽屉,我想要在底部导航抽屉上方可见。如何在使用导航抽屉的片段时在底部导航栏上添加导航抽屉?
什么我是这样的:
我想实现的是这个
我的片段于版图
<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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
>
<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 xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:paddingTop="?attr/actionBarSize"
android:layout_gravity="start"
>
<android.support.v7.widget.RecyclerView
android:id="@+id/panels_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</android.support.design.widget.NavigationView>
我的活动 -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/activity_main"
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"
tools:context="com.example.harshitaneja.homie.MainActivity">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/navigation_main"
android:animateLayoutChanges="true"
android:id="@+id/frame_layout">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary"
app:itemIconTint="@color/nav_item_state_list"
app:itemTextColor="@color/nav_item_state_list"
app:menu="@menu/bottom_navigation_items">
</android.support.design.widget.BottomNavigationView>
</RelativeLayout>
我很抱歉,如果我做了任何错误,同时问这个问题,因为这是我的第一个问题在这里。谢谢
答
将您的android.support.design.widget.BottomNavigationView
移动到您的content_main
。让您的活动将只包含一个视图组,分片将包含抽屉和bottomNavigationView这样
<DrawerLayout>
<CoordintorLayout>
<AppBarLayout>
</AppBarLayout>
<LinearLayout
android:orientation="vertical">
<include layout="@layout/content_main" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorPrimary"
app:itemIconTint="@color/nav_item_state_list"
app:itemTextColor="@color/nav_item_state_list"
app:menu="@menu/bottom_navigation_items">
</LinearLayout>
</CooorDinatorLayout>
</DrawerLayout>
显示您的布局XML代码 – Sony
@Sony加我想到了这一点的布局 – Harshit