Android 为什么这个空白出现在appbar布局下面?
我不知道是什么原因造成了这一空间。这一定是一些我不知道的xml文件。这是一个很好的片段:Android 为什么这个空白出现在appbar布局下面?,android,xml,android-layout,kotlin,android-fragments,Android,Xml,Android Layout,Kotlin,Android Fragments,我不知道是什么原因造成了这一空间。这一定是一些我不知道的xml文件。这是一个很好的片段: 这是安卓团队的一个bug。 除了希望他们把它修好,你什么也做不了。 除非你自己做。这是安卓团队的错误。 除了希望他们把它修好,你什么也做不了。 除非你自己做。如前所述,这是安卓方面的一个bug。解决方案是在线性布局内部使用相对布局,并为相对布局分配10的权重,以使其覆盖整个屏幕: <LinearLayout xmlns:android="http://schemas.android.c
这是安卓团队的一个bug。
除了希望他们把它修好,你什么也做不了。
除非你自己做。这是安卓团队的错误。
除了希望他们把它修好,你什么也做不了。
除非你自己做。如前所述,这是安卓方面的一个bug。解决方案是在线性布局内部使用相对布局,并为相对布局分配10的权重,以使其覆盖整个屏幕:
<LinearLayout 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:orientation="vertical"
android:background="@android:color/holo_green_dark"
android:weightSum="10">
<RelativeLayout
android:layout_weight="10"
android:layout_width="match_parent"
android:layout_height="0dp">
</RelativeLayout>
</LinearLayout>
如前所述,这是安卓方面的一个bug。解决方案是在线性布局内部使用相对布局,并为相对布局分配10的权重,以使其覆盖整个屏幕:
<LinearLayout 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:orientation="vertical"
android:background="@android:color/holo_green_dark"
android:weightSum="10">
<RelativeLayout
android:layout_weight="10"
android:layout_width="match_parent"
android:layout_height="0dp">
</RelativeLayout>
</LinearLayout>
当您添加到主活动资源文件:fitsSystemWindows=true时,该错误会出现。当您添加到主活动资源文件:fitsSystemWindows=true时,该错误会出现
<LinearLayout 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:orientation="vertical"
android:background="@android:color/holo_green_dark"
android:weightSum="10">
<RelativeLayout
android:layout_weight="10"
android:layout_width="match_parent"
android:layout_height="0dp">
</RelativeLayout>
</LinearLayout>