No resource identifier found for attribute 'layout_behavior' in package

后端 未结 11 975
不知归路
不知归路 2020-11-30 05:43

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:

Error:(26) No

相关标签:
11条回答
  • 2020-11-30 06:01

    Just in case someone else comes from Google and makes the same mistake I did, it's layout_behaviOr, not layout_behavioUr.

    0 讨论(0)
  • 2020-11-30 06:07

    Replace "app:layout_behavior="@string/appbar_scrolling_view_behavior" with app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"

    0 讨论(0)
  • 2020-11-30 06:10

    Add compile com.android.support:design:23.0.1 into your build.gradle dependencies.

    0 讨论(0)
  • 2020-11-30 06:11

    if you not added android material yet first add this line in your dependencies in build.gradle file

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

    then use this attribute instead

    app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
    
    0 讨论(0)
  • 2020-11-30 06:14

    Note: The versions have changed by now, so replace below versions with the most recent ones.

    The accepted answer gets rid of the error in case layout_behavior is not needed, however if you actually want to use:

    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    

    Make sure to add the proper dependency to the build.gradle file of your module:

    apply plugin: 'com.android.library'
    
    android {
        compileSdkVersion 23
        buildToolsVersion "21.1.2"
    
       //Other stuff....
    }
    
    dependencies {
    
        //Importing the design library fixes the build
        compile 'com.android.support:design:23.1.0'
    
        //Other libraries....
    }
    

    I.e. add this line to your dependencies:

    compile 'com.android.support:design:23.1.0'
    
    0 讨论(0)
提交回复
热议问题