本文介绍了AndroidX中"AppBarLayout $ ScrollingViewBehavior"的替代方案是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将我的项目迁移到了AndroidX.现在,当我打开包含以下代码的应用程序的特定页面时,该应用程序崩溃

I've recently migrated my project to AndroidX. Now when I open specific page of the app that has code below, the app Crashes

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="fill_vertical"
    android:clipToPadding="false"
    app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
    >

Logcat错误:

android.view.InflateException: Binary XML file line #119: Could not inflate Behavior subclass android.support.design.widget.AppBarLayout$ScrollingViewBehavior
    Caused by: java.lang.RuntimeException: Could not inflate Behavior subclass android.support.design.widget.AppBarLayout$ScrollingViewBehavior

我认为我必须用AndroidX中的替代方法替换此行为.但是那是什么替代代码?我在 https://developer.android.com/jetpack/androidx/migrate 中搜索.但是找不到AppBarLayout.

I think I must replace this behavior with it's alternative in AndroidX. But what is that alternative code?I searched in https://developer.android.com/jetpack/androidx/migrate. But didn't find AppBarLayout.

谢谢.

推荐答案

我找到了解决方案.layout_behavior行必须替换为:

I found the solution.The layout_behavior line must be replace with this:

app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"

确保build.gradle中存在此依赖项:

make sure this dependency exists in build.gradle:

implementation 'com.google.android.material:material:1.0.0'

这篇关于AndroidX中"AppBarLayout $ ScrollingViewBehavior"的替代方案是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 10:22