首先,我想澄清一下,關於此的很多內容已經編寫完成,我已經閱讀了一些帖子,但他們會說我常見的一些內容讓他們完成。下載最新的支持庫版本,支持庫版本等。另外,我正在編譯最新的可用SDK版本。我的問題是爲浮動操作按鈕添加樣式,以及爲RecyclerView添加示例app:layout_behavior時。這使我產生了同樣的問題。其實我試圖在一個較舊的應用程序介紹材料設計。隨着新的我沒有問題,但我已經檢查和配置是相同的。我錯過了什麼嗎?錯誤沒有找到與給定名稱相匹配的資源:Android Studio中的attr'borderWidth'
這是我目前的配置。
模塊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()
}
}
下面是導致我與邊框寬度,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>
這是我的佈局。如果我刪除浮動操作按鈕及其樣式,那麼問題出在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>
在此先感謝!
你有'編譯「com.android.support:appcompat- v7:23。+「'作爲依賴? –
當然,我更新了反映我的依賴關係的build.gradle文件。 –