2017-04-11 151 views
3

我在我的應用程序上使用BottomNavigationView。 像內容重疊BottomNavigationView

<?xml version="1.0" encoding="utf-8"?> 
<android.support.design.widget.CoordinatorLayout 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" 
    android:fitsSystemWindows="true" 
    tools:context="wormhole.musicx.activity.Artist_Details"> 
<android.support.design.widget.AppBarLayout 
    android:id="@+id/app_bar" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/app_bar_height" 
    android:fitsSystemWindows="true" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/toolbar_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     app:contentScrim="@android:color/transparent" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 



     <ImageView 
      android:id="@+id/artistArt" 
      android:layout_width="match_parent" 
      android:layout_height="280dp" 
      android:scaleType="centerCrop" 
      android:src="@drawable/album" 
      android:transitionName="@string/albumInageTransition" 
      app:layout_collapseMode="parallax" /> 


     <View 
      android:layout_width="match_parent" 
      android:layout_height="80dp" 
      android:layout_alignBottom="@+id/image" 
      android:layout_gravity="bottom" 
      android:background="@drawable/scrim_bottom" /> 

     <TextView 
      android:id="@+id/albumDetails" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:layout_marginBottom="5dp" 
      android:layout_marginLeft="35dp" 
      android:layout_marginTop="10dp" 
      android:text="fwefbwe" 
      android:textSize="17sp" 
      app:layout_anchor="@id/toolbar_layout" 
      app:layout_anchorGravity="bottom|end" 
      app:layout_collapseMode="parallax" 
      app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" /> 


     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_collapseMode="pin" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.CollapsingToolbarLayout> 
</android.support.design.widget.AppBarLayout> 

<include layout="@layout/content_artist__details" /> 

<android.support.design.widget.BottomNavigationView 
    android:id="@+id/navigation" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom" 
    android:background="?android:attr/windowBackground" 
    app:menu="@menu/navigation" 
    /> 


<android.support.design.widget.FloatingActionButton 
    android:id="@+id/fab" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_margin="@dimen/fab_margin" 
    app:layout_anchor="@id/app_bar" 
    app:layout_anchorGravity="bottom|end" 
    app:srcCompat="@drawable/ic_favourite" /> 

content_artist__details

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView 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" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="wormhole.musicx.activity.Artist_Details" 
    tools:showIn="@layout/activity_artist__details" 
    android:layout_marginBottom="20dp"> 

<android.support.v7.widget.RecyclerView 
    android:visibility="visible" 
    android:id="@+id/songListArtistRec" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

</android.support.v7.widget.RecyclerView> 

我取了included layout的內容的問題是下BottomNavigationView去。 無法弄清楚我該怎麼做。

我想content_artist__details的內容恰好高於BottomNavigationView

+0

你有沒有用'layout_marginBottom'試過'content_artist__details' ? – Sudarshan

+0

我做了,但是這可能無法在不同的設備上正常工作,我想。 –

+0

您是否曾嘗試將''放入'LinearLayout'中並將BNV取出? – AlexGuerra

回答

0

你可以嘗試使用layout_marginBottom = "@dimen/app_bar_height"

既然你在嵌套佈局只有RecyclerView你可以更新你的代碼是這樣的,

<android.support.v7.widget.RecyclerView 
    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:visibility="visible" 
    android:id="@+id/songListArtistRec" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context="wormhole.musicx.activity.Artist_Details" 
    tools:showIn="@layout/activity_artist__details" 
    android:layout_marginBottom="@dimen/app_bar_height"/>