[英]Error No resource found that matches the given name: attr 'borderWidth' in Android Studio
First of all I would like to clarify that a lot about this has been written, I've read some posts but the common things they say I have them done. 首先,我想澄清的是,有关此方面的文章很多,我读了一些帖子,但是他们说我已经完成了一些常见的事情。 Download the latest Support Library version, Support repository version, etc. Also I'm compiling against the latest available SDK version.
下载最新的支持库版本,支持存储库版本等。另外,我正在根据最新的可用SDK版本进行编译。 My problem is when adding styles for the Floating Action Button and when adding for example app:layout_behavior for the RecyclerView.
我的问题是为“浮动操作按钮”添加样式时,以及为RecyclerView添加例如app:layout_behavior时。 That causes me the same kind of problems.
那给我造成了同样的问题。 Actually I'm trying to introduce the Material design in an older app.
实际上,我正在尝试在较旧的应用程序中介绍Material设计。 With the new ones I have no problems, but I've checked and the configuration is the same.
有了新的,我没有问题,但是我检查了一下,配置是一样的。 Am I missing something?
我想念什么吗?
Here is my current configuration. 这是我当前的配置。
Module build.grade: 模块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'
}
Top level build.gradle: 顶级build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Here are the styles causing me problems with borderWidth, pressedTranslationZ and rippleColor: 这是导致我的borderWidth,PressedTranslationZ和波纹颜色问题的样式:
<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>
Here is my layout. 这是我的布局。 If I remove the Floating Action Button along with its styles, then the problem is with the layout_behaviour of the RecyclerView.
如果删除浮动操作按钮及其样式,则问题出在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>
Thanks in advance! 提前致谢!
根据Android开发者文档 ,“浮动操作”按钮属于android.support.design.widget.FloatingActionButton,这意味着您应添加
compile 'com.android.support:design:23+'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.