在包中找不到属性“layout_behavior"的资源标识符 [英] No resource identifier found for attribute 'layout_behavior' in package

查看:24
本文介绍了在包中找不到属性“layout_behavior"的资源标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我尝试向其中添加库之前,我的应用程序运行良好.添加库后,Android Studio 给了我以下错误:

My application worked fine until I tried to add a library to it. After I added the library, Android Studio gives me the following error:

错误:(26) 找不到属性的资源标识符inf.."包中的layout_behavior"

Error:(26) No resource identifier found for attribute 'layout_behavior' in package 'inf..'

这是我的 build.gradle 文件:

This is my build.gradle file:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.ogaclejapan.smarttablayout:utils-v4:1.3.0@aar'
    compile 'com.ogaclejapan.smarttablayout:library:1.3.0@aar'
    compile 'com.jpardogo.materialtabstrip:library:1.1.0'
    // compile 'com.lorentzos.swipecards:library:1.0.9@aar'
    compile 'com.android.support:cardview-v7:21.0.3'
    compile 'com.android.support:recyclerview-v7:21.0.3'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
    compile project(':swipelib')
}

这是导致错误的xml:

This is the xml which causes the error:

 <android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

我尝试了以下方法:

  • 删除了库
  • 重置 Android Studio 和我的电脑
  • 从 git 恢复到我以前版本的代码.

但是,错误仍然存​​在.我该如何解决?

However, the error persists. How do I resolve this?

推荐答案

该字符串资源在 Material Design 支持库中定义.

That string resource is defined within the Material Design support library.

由于您没有使用 Material Design 支持库中的 CoordinatorLayout,您应该能够安全地删除 app:layout_behavior 属性.它可能被削减 &从其他代码粘贴.

Since you're not using the CoordinatorLayout from the Material Design support library, you should be able to safely remove the app:layout_behavior attribute. It was probably cut & paste from other code.

注意:如果您实际上正在使用 CoordinatorLayout 并希望协作滚动行为起作用,则需要将最新版本的 Material Design Support 库的依赖项添加到您的 Gradle 构建文件中:

NOTE: If you are actually using CoordinatorLayout and want the cooperative scrolling behaviors to work, you need to add the dependency for the latest version of the Material Design Support library to your Gradle build file:

compile 'com.android.support:design:23.0.1'

<小时>

更新:请注意,在最新版本的 Gradle 中,compile 配置已被弃用,取而代之的是 implementationapi 配置,因此您的依赖可能看起来像这样:


UPDATE: Note that with the latest versions of Gradle the compile configuration has been deprecated in favor of implementation and api configurations so your dependency could look like this:

implementation 'com.android.support:design:27.0.2'

这只是一个例子;当您阅读本文时,版本号可能已过时,因此请确保您的版本与您要使用的支持库的版本相匹配.

This is only an example; the version numbers may be out of date when you read this, so make sure your version matches the version of the support library that you want to use.

更多信息:实现和编译有什么区别在gradle中

这篇关于在包中找不到属性“layout_behavior"的资源标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆