[英]no resource id found for app:layout_scrollflags from CollapsingToolbarLayout
The title of this question basically says it all.这个问题的标题基本上说明了一切。 I get the error: no resource identifier found for app:layout_scrollflags from CollapsingToolbarLayout.
我收到错误:没有为来自 CollapsingToolbarLayout 的 app:layout_scrollflags 找到资源标识符。 I use eclipse and imported the design library jar file.
我使用eclipse并导入了设计库jar文件。 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示例: http : //android-developers.blogspot.in/2015/05/android-design-support-library.html
only importing the design library jar file is not enough.仅导入设计库 jar 文件是不够的。 You need to import resource of android-design-library project while the jar file only contains class files.
您需要导入android-design-library项目的资源,而jar 文件仅包含类文件。
Do as I say:照我说的做:
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 .你必须这样做,因为
xmlns:app="http://schemas.android.com/apk/res-auto"
意味着你需要来自你的库项目或当前项目的本地资源,在这种情况下,这意味着你需要来自android-design-library库项目的资源。
try this尝试这个
add app level build.gradle添加应用级build.gradle
compile 'com.android.support:design:24.2.1'
then Build -> Rebuild Project然后构建->重建项目
As others have stated you definitely need to add Design Support Library dependency to your android app.正如其他人所说,您肯定需要向您的 android 应用程序添加设计支持库依赖项。 Simplest way is to add following to app level gradle file -
最简单的方法是将以下内容添加到应用程序级别的 gradle 文件中 -
compile 'com.android.support:design:25.3.1'
However couple of points to note-不过有几点需要注意——
compileSdkVersion 25
I had to use compile 'com.android.support:design:25.3.1'
and not compile 'com.android.support:design:24.2.1'
compileSdkVersion 25
我不得不使用compile 'com.android.support:design:25.3.1'
而不是compile 'com.android.support:design:24.2.1'
android:Theme.Material
due to which it was failing.android:Theme.Material
因为它失败了。 Changing it to Theme.AppCompat.Light.NoActionBar
worked for me.Theme.AppCompat.Light.NoActionBar
对我Theme.AppCompat.Light.NoActionBar
。 If you are using AndroidX the above solutions won't work .如果您使用的是AndroidX ,上述解决方案将不起作用。
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:请注意,也许您需要使
Invalidate Caches/Restart
才能为您工作:
File > Invalidate Caches/Restart
文件 > 使缓存无效/重新启动
For more info check the Migrating to AndroidX page .有关更多信息,请查看迁移到 AndroidX 页面。
尝试将此代码添加到 xml 文件中:
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
For this you should use this type of hierarchy of layouts.为此,您应该使用这种类型的布局层次结构。 Make sure the design support library is included as a reference project in the case of eclipse
确保设计支持库在 eclipse 的情况下作为参考项目包含在内
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" >
<android.support.design.widget.AppBarLayout
android:id="@+id/appbarlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true" >
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp" >
<ImageView
android:id="@+id/ivProfileImage"
android:layout_width="match_parent"
android:layout_height="250dp"
app:layout_collapseMode="parallax"
android:contentDescription="@null"
android:fitsSystemWindows="true"
android:minHeight="100dp"
android:scaleType="fitXY" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:layout_gravity="fill_vertical"
app:layout_anchorGravity="top|start"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
</android.support.v4.widget.NestedScrollView>
Here is how I did这是我做的
C:\\Productivity\\android-sdks\\extras\\android\\support\\v7\\appcompat
C:\\Productivity\\android-sdks\\extras\\android\\support\\v7\\appcompat
and Check copy into workspace in import project dialog box.并在导入项目对话框中检查复制到工作区。
Project->Properties->Android
项目->属性->Android
it should remove all compilation error.它应该删除所有编译错误。
C:\\Productivity\\android-sdks\\extras\\android\\support\\design
C:\\生产力\\android-sdks\\extras\\android\\support\\design
follow same steps to import project mentioned in 1 & 2.按照相同的步骤导入 1 和 2 中提到的项目。
Project->Properties->Android.
项目->属性->Android。
Finally add design and appcompat to build path of Your Android project最后添加 design 和 appcompat 来构建你的 Android 项目的路径
Project->Properties->Android项目->属性->Android
clean and build your project with Android 6.0 all compilation errors must be gone by now.使用 Android 6.0 清理并构建您的项目,所有编译错误现在都必须消失。
Congrats now you can use material design in Eclipse.Hope it will help somebody恭喜你现在可以在 Eclipse 中使用材料设计。希望它会帮助某人
Add an app level build.gradle添加应用级 build.gradle
implementation 'com.android.support:design:28.0.0'
the version should match to your compileSdkVersion.版本应与您的 compileSdkVersion 匹配。 I used version 28.
我用的是28版。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.