作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚实现了一个底部导航(AS的默认-文件->新建-> Activity ->底部导航 Activity )一切都很好,除了nav_host_fragment
顶部的空间。 .
由于它是在 ConstraintLayout 中生成的,因此我尝试清理约束并使用 parent
设置顶部约束, 设置 margin
为 '0dp' 并设置 height
至match_constraint
.
我没有成功地删除约束并一遍又一遍地尝试。
我用了Clean Project
.
我更改为 RelativeLayout 并设置如下参数:
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/nav_view"
app:defaultNavHost="true"
app:navGraph="@navigation/mobile_navigation" />
nav_host_fragment
之间的空格顶部仍然存在。
<RelativeLayout 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="?android:attr/windowBackground"
app:menu="@menu/bottom_nav_menu" />
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/nav_view"
app:defaultNavHost="true"
app:navGraph="@navigation/mobile_navigation" />
</RelativeLayout>
最佳答案
删除 此行来自您的相对布局 .
android:paddingTop="?attr/actionBarSize"
关于android - 无法删除 nav_host_fragment 顶部的空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57628238/
我刚刚实现了一个底部导航(AS的默认-文件->新建-> Activity ->底部导航 Activity )一切都很好,除了nav_host_fragment顶部的空间。 . 由于它是在 Constr
我是一名优秀的程序员,十分优秀!