android - 约束布局重叠工具栏
问题描述
我的布局有问题。我正在尝试将约束布局放置在工具栏下方。但是,它决定要重叠工具栏。我试过使用 app:layout_behavior="@string/appbar_scrolling_view_behavior" 没有运气。
工具栏正在另一个 xml 文件中创建并使用 include 调用。
下面的活动
<android.support.v4.widget.DrawerLayout
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:id="@+id/drawer_layout"
android:fitsSystemWindows="true"
tools:context="XXXXXX"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<include
android:id="@+id/test1234"
layout="@layout/app_bar_home"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_menu" />
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toBottomOf="@id/test1234">
**Bunch of constraints here etc**
**Bunch of buttons here**
</android.support.constraint.ConstraintLayout>
</android.support.v4.widget.DrawerLayout>
编辑
在 android studio 的设计视图中显示时很好。但是,当在手机或模拟器上打开时,它仍然坏了。
模拟时,应用程序仍然看起来像第二个图像。
解决方案
我遇到了同样的问题,然后我用这个破解了它。在你的约束布局中,写这个
android:layout_marginTop="?attr/actionBarSize"
推荐阅读
- python - Python:创建一个模块并在模块的上下文中评估一个字符串?
- vba - 使用 Selenium 绕过 Recaptcha 时 VBA 中的自动化错误
- javascript - Firebase:没有创建 Firebase 应用“[DEFAULT]”
- c# - 如何获取字符串数据类型中 Timeduration 存储的平均值?
- visual-studio-code - 从 VScode 面包屑导航栏中隐藏父目录名称
- python - [SSL] PEM Lib <_ssl.c:3932> 对 python Flask ssl 意味着什么?
- javascript - 在浏览器中使用 aws kinesis 创建视频流的推荐方法
- vue.js - 如何在 VueJS 中使用 Bootstrap Dualist 框
- python - 有什么方法可以运行全部或部分 py 文件并保持结果状态?
- python - PyOpenGL。glVertexPointer 将 RAM 加载到无穷大