4nd*_*o1d 4 android drawerlayout bottomnavigationview
我需要使用这两个元素,这就是我目前所拥有的:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.DrawerLayout 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:openDrawer="start">
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorAccent"
app:menu="@menu/menu_bottom" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我的问题是BottomNavigationView
位于 前面NavigationView
,但情况不应该如此(我说的是 y 索引)。我也尝试使用 aCoordinatorLayout
代替,但随后卡BottomNavigationView
在显示器的顶部。
我将简单地用作DrawerLayout
根元素,并且在其中DrawerLayout
您可以放置一个用于包含主屏幕的布局和一个NavigationView
用于菜单的布局。之后您可以将 BottomNavigationView 放入主布局中。
<android.support.v4.widget.DrawerLayout 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:openDrawer="start">
<include layout="@layout/maincontent"/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
maincontent.xml
<FrameLayout..>
...
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorAccent"
app:menu="@menu/menu_bottom" />
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6727 次 |
最近记录: |