Android 到底是什么原因导致导航主机上默认有填充?
这是我第一次尝试constraint布局,我已经断断续续地用了大约一天的时间。我使用Android Studio 4创建了一个带有默认项目设置的底部导航活动。它在导航主机上包含一个paddingTop,导致我的内容无法展开/滚动到应用程序顶部。如果我去掉这个填充物,那么我最初的问题就消失了,但这给我留下了问题 我是不是把它移走了而把它弄坏了?我有点担心没有这个填充物以后不会有什么东西出现 为什么我要在其他布局/项目中使用此功能?我很确定移除它对我来说是正确的选择,但它在启动项目中。对我来说,这似乎是对屏幕的无用浪费,所以我是否缺少用例 我知道这与类似,但我正在寻找为什么它是默认值,或者为什么填充会有帮助 fragment_monster.xml——这是nav主机内部加载的内容片段Android 到底是什么原因导致导航主机上默认有填充?,android,android-constraintlayout,Android,Android Constraintlayout,这是我第一次尝试constraint布局,我已经断断续续地用了大约一天的时间。我使用Android Studio 4创建了一个带有默认项目设置的底部导航活动。它在导航主机上包含一个paddingTop,导致我的内容无法展开/滚动到应用程序顶部。如果我去掉这个填充物,那么我最初的问题就消失了,但这给我留下了问题 我是不是把它移走了而把它弄坏了?我有点担心没有这个填充物以后不会有什么东西出现 为什么我要在其他布局/项目中使用此功能?我很确定移除它对我来说是正确的选择,但它在启动项目中。对我来说,这似
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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=".ui.monster.MonsterFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:fontFamily="sans-serif"
android:textColor="#9B2818"
android:textSize="34sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Pixie" />
<!-- I have other elements here in the screeenshot, but removing them doesn't help. -->
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize">
<!-- Removing this paddingTop fixes my issue, but I don't get why it's there to begin with. -->
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
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="wrap_content"
app:defaultNavHost="true"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>