【问题标题】:Content overlapping on BottomNavigationViewBottomNavigationView 上的内容重叠
【发布时间】:2017-04-11 17:20:43
【问题描述】:

我在我的应用上使用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 的上方。

【问题讨论】:

  • 您尝试过在content_artist__details 上使用layout_marginBottom 吗?
  • 我做到了,但我认为这在不同的设备上可能无法正常工作。
  • 您是否尝试将&lt;include&gt; 放入LinearLayout 并将BNV 取出?
  • 是的,但没有解决我的问题。
  • 发布您的完整 xml

标签: android overlap bottomnavigationview


【解决方案1】:

你可以试试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"/>

【讨论】:

    猜你喜欢
    • 2018-06-03
    • 2021-11-29
    • 1970-01-01
    • 2017-09-09
    • 1970-01-01
    • 2018-02-17
    • 1970-01-01
    • 2020-01-03
    • 2018-02-13
    相关资源
    最近更新 更多