错误找不到与给定名称匹配的资源:Android Studio 中的 attr 'borderWidth'

Error No resource found that matches the given name: attr 'borderWidth' in Android Studio

首先,我想澄清一下,关于这方面的内容已经写了很多,我已经阅读了一些帖子,但他们说的常见事情我已经完成了。下载最新的支持库版本、支持存储库版本等。另外,我正在针对最新的可用 SDK 版本进行编译。我的问题是在为浮动操作按钮添加样式时以及在为 RecyclerView 添加例如 app:layout_behavior 时。这给我带来了同样的问题。实际上,我正在尝试在旧版应用程序中引入 Material 设计。使用新的我没有问题,但我已经检查过并且配置是相同的。我错过了什么吗?

这是我当前的配置。

模块 build.grade:

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.2'
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.xxx"
        minSdkVersion 16
        targetSdkVersion 23
        // Enabling multidex support.
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    lintOptions {
        disable 'MissingTranslation'
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support:recyclerview-v7:23.2.0'
    compile 'com.google.android.gms:play-services-plus:8.4.0'
    compile 'com.google.android.gms:play-services-auth:8.4.0'
}

顶级build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

以下是导致我出现 borderWidth、pressedTranslationZ 和 rippleColor 问题的样式:

<style name="FabStyle">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_margin">@dimen/fab_compat_margin</item>
    <item name="android:src">@drawable/ic_action_add</item>
    <item name="borderWidth">0dp</item>
    <item name="elevation">6dp</item>
    <item name="pressedTranslationZ">12dp</item>
    <item name="rippleColor">@android:color/white</item>
</style>

这是我的布局。如果我删除 Floating Action Button 及其样式,那么问题出在 RecyclerView 的 layout_behaviour。

<RelativeLayout
    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"
    tools:context="com.egane.BaseCustomersActivityActivity">

    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CoordinatorLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <android.support.v7.widget.RecyclerView
                android:id="@android:id/list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

            <android.support.design.widget.AppBarLayout
                android:id="@+id/appBarLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="?attr/colorPrimary"
                    app:layout_scrollFlags="scroll|enterAlways"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>

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

            <android.support.design.widget.FloatingActionButton
                android:id="@+id/fab"
                style="@style/FabStyle"
                android:layout_gravity="bottom|end"/>

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

        <android.support.design.widget.NavigationView
            android:id="@+id/navigation_view"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_gravity="start"
            app:headerLayout="@layout/drawer_header"
            app:menu="@menu/drawer"/>

    </android.support.v4.widget.DrawerLayout>

</RelativeLayout>

提前致谢!

根据 Android developer documentation,浮动操作按钮属于 android.support.design.widget.FloatingActionButton,这意味着您应该添加

compile 'com.android.support:design:23+'