【问题标题】:Error: attribute 'package:contentScrim' not found错误:找不到属性“包:contentScrim”
【发布时间】:2018-06-13 23:41:06
【问题描述】:

当我尝试折叠工具栏布局时,我在 contentScrim 上找不到错误。 这是我的 XML 文件。

<?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>

我已经看过 GitHub 和其他网站上的所有教程。并使用但我无法得到解决方案。片段的视差粘性标头的任何简单方法。现在我正在关注https://android.jlelse.eu/parallax-scrolling-header-tabs-android-tutorial-2cc6e40aa257的代码,并查看android开发人员关于CollapsingToolbarLayout的文档。

【问题讨论】:

    标签: android fragment parallax


    【解决方案1】:

    我不知道您究竟为什么会收到该错误,但这可能是一个好的开始。

    https://stackoverflow.com/a/31180719/7900721

    否则我发现这个关于掌握协调器布局的非常好的教程,它有一个 github 存储库,其中包含一堆很好的示例,其中包含折叠工具栏布局,这在我开发时帮助了我。

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

    【讨论】:

    • 非常感谢,我会尝试一次。
    【解决方案2】:

    尝试将此添加到您的应用 build.gradle:

    dependencies {
    ...
        implementation 'com.google.android.material:material:1.1.0'
    ...
    }
    

    【讨论】:

      猜你喜欢
      • 2019-02-06
      • 2019-03-08
      • 2014-06-24
      • 1970-01-01
      • 2020-08-25
      • 2013-02-07
      • 2021-04-09
      • 2021-12-11
      • 2020-11-22
      相关资源
      最近更新 更多