Error inflating class com.google.android.material.appbar.AppBarLayout
出现了上述错误,应用程序不能运行。我上网查了足够多的资料,但每个人都告诉我检查gradle,或者只有一个旧版本的例子,所以我别无选择,只能发一个问题。
<?xml version="1.0" encoding="utf-8"?>
<layout 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"
tools:context=".scenarios.sample.view.fragment.SampleFragment">
<variable
name="sampleViewModel"
type="com.project.viewmodel.SampleViewModel" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@={sampleViewModel.sampleText}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn_sample_test"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:text="Button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:onSafeClick="@{()-> sampleViewModel.sampleBtnClickEvent()}" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
我的gradle
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
我不知道问题出在哪里,你能告诉我我做错了什么吗?
安卓协调器布局如何使用?
0
人关注
1
个评论
Try implementing
implementation 'com.android.support:design:28.0.0'
.
Duseop
发布于
2021-07-04
2
个回答
SamanSepahvand
发布于
2021-07-09
0
人赞同
Try This:
def materialVersion='1.3.0-alpha03'
implementation "com.google.android.material:material:$materialVersion"