2017-05-05 8 views
0

組み合わせて、これは私が現時点で持っているものである方法:適切に私は両方の要素を使用する必要がNavigationViewと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> 

ここに私の問題はBottomNavigationViewは、NavigationViewの前でどれがいけないということです(私はy指数について話している)場合である。私はまたCoordinatorLayoutを代わりに使ってみましたが、BottomNavigationViewがディスプレイの上部に貼り付けられています。

答えて

0

DrawerLayoutをルート要素として使用し、DrawerLayoutの内部には、メイン画面を含むレイアウトとメニューのNavigationViewを配置することができます。 BottomNavigationViewをメインレイアウトに配置することができます。

maincontent.xml

<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>  
でframeLayoutがサポートされていない

<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>  
+0

'アンドロイド:layout_alignParentBottom'。 'RelativeLayout'と一緒に行くほうがいい – PYPL

関連する問題