【发布时间】:2020-09-13 22:24:09
【问题描述】:
我是 Android Studio 的新手,我在启动应用程序时没有在顶部定义这个空白,但在 Android Studio 的预览屏幕中没有定义:
我不知道它来自哪里,因为我的定义 XML 的顶部没有定义这个空格:
<?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"
android:id="@+id/scrollContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/containerLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
这只是上面显示的一个内的另外两个线性布局。我试过只添加文本,但仍然出现空格。我也没有在代码中添加任何内容。
任何帮助/想法将不胜感激!
编辑:下面是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">
<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="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
【问题讨论】:
-
这个 xml 是 Fragment 还是 Activity 的布局,还是别的什么?
-
这是一个片段
-
您能否发布托管此 Fragment 的 Activity 布局的 xml?
-
我是 Android Studio 的新手,只有一个活动 XML,所以我在上面添加了它
标签: android android-studio mobile-application