no resource id found for app:layout_scrollflags from CollapsingToolbarLayout
Solution 1
only importing the design library jar file is not enough. You need to import resource of android-design-library project while the jar file only contains class files.
Do as I say:
- import android-design-library project. The project is at "sdk/extras/android/support/design/". And set it as a library project if it is not.
- import the above project into your main project as a library.
You have to do this, because xmlns:app="http://schemas.android.com/apk/res-auto"
means your need local resources from your library project or the current project, in this case, it means you need resources from the library project of android-design-library.
Solution 2
try this
add app level build.gradle
compile 'com.android.support:design:24.2.1'
then Build -> Rebuild Project
Solution 3
As others have stated you definitely need to add Design Support Library dependency to your android app. Simplest way is to add following to app level gradle file -
compile 'com.android.support:design:25.3.1'
However couple of points to note-
- This support library should not use a different version than the compileSdkVersion. Since I was using
compileSdkVersion 25
I had to usecompile 'com.android.support:design:25.3.1'
and notcompile 'com.android.support:design:24.2.1'
- Using the design library requires using theme.appcompat or a descendant. If you want add actionbar to your activity then your theme should be AppCompat. In my case I was using
android:Theme.Material
due to which it was failing. Changing it toTheme.AppCompat.Light.NoActionBar
worked for me.
Solution 4
Androidx soution:
If you are using AndroidX the above solutions won't work.
You will need to implement this:
implementation 'com.google.android.material:material:1.1.0-alpha06'
Notice that Maybe you will need to Invalidate Caches/Restart
for this to work for you:
File > Invalidate Caches/Restart
For more info check the Migrating to AndroidX page.
Solution 5
Try add this code to the xml file:
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
DennisVA
Updated on April 26, 2020Comments
-
DennisVA about 4 years
The title of this question basically says it all. I get the error: no resource identifier found for app:layout_scrollflags from CollapsingToolbarLayout. I use eclipse and imported the design library jar file. I'm able to use the design support layouts in my classes so that's correct
this is a piece of the code i use:
<LinearLayout 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" android:orientation="vertical" android:background="@color/activityBg" tools:context=".MainActivity" > <android.support.design.widget.AppBarLayout android:layout_height="wrap_content" android:layout_width="match_parent"> <android.support.design.widget.CollapsingToolbarLayout android:layout_width="match_parent" android:layout_height="match_parent" app:layout_scrollFlags="scroll|exitUntilCollapsed"> <include layout="@layout/toolbar"/> </android.support.design.widget.CollapsingToolbarLayout> </android.support.design.widget.AppBarLayout>
examples: http://android-developers.blogspot.in/2015/05/android-design-support-library.html
-
DennisVA almost 9 yearsstill doesn't work after i put the whole thing in a appbarlayout
-
Gopal Singh Sirvi almost 9 yearstry to remove linear layout and put it in a cordinator layout and the other content in nested scroll view. I recently implemented it and it is working fine
-
DennisVA almost 9 yearsdid u use eclipse or android studio?
-
DennisVA almost 9 yearsdid you add any jars to get the design support library to work other then appcompat v4/v7
-
Gopal Singh Sirvi almost 9 yearsNo just used the project design
(design support library)
from sdk as a reference project. -
Gopal Singh Sirvi almost 9 yearsLet us continue this discussion in chat.
-
Sushant over 8 yearsi got errors in design library after importing at style.xml file
-
SilentKnight about 8 yearsCan you provide more details?
-
Bhunnu Baba about 7 yearsWill sdk level 23 work instead of 24 in this condition?
-
A.G.THAMAYS almost 7 yearsyes, you should change from compile 'com.android.support:design:23._._' to compile 'com.android.support:design:24.2.1' you need not use 24.2.1.. you can replace new version
-
mobibob about 3 years'compile' is deprecated and must use 'api' (precompiled library). The version has to match your compiler. The IDE sync will provide the proper aids.