简体   繁体   English

底部导航活动模板中标题和片段之间的差距

[英]Gap between title and fragment in Bottom Navigation Activity template

I was checking out the Android Studio's Bottom Navigation Activity project template, and found that that is a gap between the 'title' and 'home fragment'.我正在查看 Android Studio 的Bottom Navigation Activity项目模板,发现这是“标题”和“主页片段”之间的差距。 The only change I added was a android:background="@color/colorAccent" to the fragment_home.xml to highlight the gap?我添加的唯一更改是android:background="@color/colorAccent"fragment_home.xml以突出差距?

Is there any use of this gap?这个间隙有什么用吗? How to get rid of this gap?如何摆脱这个差距?

在此处输入图片说明

Found the cause.找到原因了。 It is due to the android:paddingTop="?attr/actionBarSize" found in 'activity_main.xml'.这是由于在“activity_main.xml android:paddingTop="?attr/actionBarSize"找到了android:paddingTop="?attr/actionBarSize"

<?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"

  >

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM