java - 在 android studios 中获得通货膨胀异常
问题描述
因此,我正在尝试为我的一项活动制作工具栏,因此我制作了布局并尝试将其包含在内,但是android.view.InflateException: Binary XML file line #9: You must specify a layout in the include tag: <include layout="@layout/layoutID" />
如果有人知道出了什么问题,我会不断收到此异常,我将不胜感激。
我的活动 UML 是
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".HelpScreen">
<include
android:id="@+id/tbar"
android:layout="@layout/help_toolbar"/>
<TextView
android:id="@+id/textView"
android:layout_width="363dp"
android:layout_height="648dp"
android:fontFamily="cursive"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:padding="10dp"
android:text="@string/firstParagraph"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.488"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.868" />
</RelativeLayout>
我的布局是
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="4dp">
</androidx.appcompat.widget.Toolbar>
提前致谢。
解决方案
你的代码:
<include
android:id="@+id/tbar"
android:layout="@layout/help_toolbar"/>
相反,您要创建:
<include
android:id="@+id/tbar"
layout="@layout/help_toolbar"/>
指定布局时,您不需要 android
推荐阅读
- java - 在春季防止来自控制器的dao调用
- python - 终端上进度条中的Python多线程异常输出
- c# - 从 C# 中的 JSON 数据中提取模式
- javascript - Nunjucks:异步自定义标签不适用于版本 > 2.3
- css - 如何使滚动捕捉在 FF 中以 body 作为滚动容器工作
- c++ - 防止用户输入会导致整数溢出的值
- php - 使用 PHP 自动增加数组值
- c# - dotnet-sonarscanner - 后处理失败 - “找不到或加载主类”
- kubernetes - Istio 服务及其使用
- java - Gradle 有没有办法使用 curl 命令解决依赖关系?