2017-10-16 63 views
0

我的應用程序由頂部的AppBarLayout,中間的FrameLayout和底部的BottomNavigationView組成。起初,FrameLayout重疊了AppBarLayout和BottomNavigationView。我設法分開AppBarLayout和FrameLayout,但似乎無法將BottomNavigationView分開。FrameLayout重疊BottomNavigationView

<android.support.design.widget.CoordinatorLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.jy.hi.Splash" 
android:background="@color/whiteBG"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 
    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbarTop" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:id="@+id/toolbar_title" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="center" 
       android:text="hi" 
       android:textColor="@color/talecolor" 
       android:textSize="22sp" /> 

     </android.support.v7.widget.Toolbar> 
    </android.support.design.widget.AppBarLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal"> 
     <FrameLayout 
      android:id="@+id/frame" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

     </FrameLayout> 

    </LinearLayout> 

</LinearLayout> 

<!--bottom--> 
<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="55dp" 
    android:id="@+id/bottomBar" 
    android:layout_gravity="bottom"> 

    <com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/bottomNavView_Bar" 
     android:background="@drawable/white_grey_border_top" 
     app:menu="@menu/bottom_navigation_menu" 
     app:itemIconTint="@color/bottom_nav_icon_color_selector" 
     app:itemTextColor="@color/bottom_nav_icon_color_selector"> 

    </com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx> 
</RelativeLayout> 

回答

0

的的LinearLayout高度被設定爲match_parent

將其更改爲wrap_content

(...) 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
(...)