Error: attribute 'package:contentScrim' not found
Asked Answered
M

2

7

While I am trying to do Collapsing Toolbar Layout I got the error on contentScrim not found. This is my XML file.

<?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:id="@+id/htab_maincontent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/htab_appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/htab_collapse_toolbar"
        android:layout_width="match_parent"
        android:layout_height="256dp"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"
        app:titleEnabled="false">

        <ImageView
            android:id="@+id/htab_header"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/header"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            app:layout_collapseMode="parallax"/>

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:alpha="0.3"
            android:background="@android:color/black"
            android:fitsSystemWindows="true"/>

        <android.support.v7.widget.Toolbar
            android:id="@+id/htab_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:layout_gravity="top"
            android:layout_marginBottom="48dp"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

        <android.support.design.widget.TabLayout
            android:id="@+id/htab_tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            app:tabIndicatorColor="@android:color/white"
            app:tabSelectedTextColor="@android:color/white"
            app:tabTextColor="@color/white_70"/>

    </android.support.design.widget.CollapsingToolbarLayout>

    </android.support.design.widget.AppBarLayout>

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

</android.support.design.widget.CoordinatorLayout>

I have seen all the tutorial on GitHub and other sites. and used but I could not get the solution. Any easy way to the parallax sticky header for the fragment. and right now I am following the code of https://android.jlelse.eu/parallax-scrolling-header-tabs-android-tutorial-2cc6e40aa257 and see the documentation of android developer about the CollapsingToolbarLayout.

Morelock answered 4/1, 2018 at 9:10 Comment(0)
M
5

I don't know why exactly you would be getting that error, but this might be a good start.

https://mcmap.net/q/425232/-no-resource-id-found-for-app-layout_scrollflags-from-collapsingtoolbarlayout

Otherwise I found this really good tutorial on mastering the coordinator layout which has a github repo with a bunch of great examples with the collapsing toolbar layout that helped me when I developed one.

http://saulmm.github.io/mastering-coordinator

Mischief answered 4/1, 2018 at 9:17 Comment(1)
Thanks a lot i ll try this once.Morelock
C
1

Try adding this to your app build.gradle:

dependencies {
...
    implementation 'com.google.android.material:material:1.1.0'
...
}
Cappuccino answered 18/3, 2020 at 21:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.