活动由底部导航栏和片段组成。该片段包含一个导航抽屉,我想在底部导航抽屉上方看到它。
我拥有的是:
我想要实现的是
我的片段布局 -
<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>
如果我在提出这个问题时犯了任何错误,我很抱歉,因为这是我的第一个问题。感谢
答案 0 :(得分:2)
将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>