【问题标题】:Bottom navigation view is overlapping some portion of the content(fragment)底部导航视图与内容的某些部分重叠(片段)
【发布时间】:2020-08-22 11:36:08
【问题描述】:

我正在使用以下 xml 代码。问题是底部导航视图与框架布局最后一项的某些部分重叠。有什么办法可以解决这个问题吗?

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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"
    tools:context=".activities.MainActivity">


    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </com.google.android.material.appbar.AppBarLayout>

    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"/>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        app:menu="@menu/bottom_navigation"
        android:background="?android:attr/windowBackground" />



</androidx.coordinatorlayout.widget.CoordinatorLayout>

【问题讨论】:

  • 要么使用边距或填充或添加虚拟Space 小部件,这是底部导航的高度,那么您必须使用LinearLayout 来扭曲FrameLayout

标签: android xml bottomnavigationview android-framelayout


【解决方案1】:

简单的解决方案是你应该将 FrameLayout 的 android:paddingBottom 设置为 BottomNavigationView 的高度

【讨论】:

    猜你喜欢
    • 2018-11-04
    • 1970-01-01
    • 2020-03-23
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多