【发布时间】:2016-12-20 12:46:16
【问题描述】:
我有一些关于以下内容的问题。
找不到与给定名称匹配的资源:attr 'colorAccent'。
找不到与给定名称匹配的资源:attr 'colorPrimary'。
找不到与给定名称匹配的资源:attr 'colorPrimaryDark'。
我做了一些研究,大部分帖子都建议使用 api level 21。 我的情况是软件必须支持 API 级别 16。
以下是我的清单文件
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="testproj.com.xxx.testproj">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Base">
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<activity android:name=".Activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
当我删除时
android:theme="@style/Theme.Base"
错误没有出现,但我的手机出现黑屏。
这是我的 gradle (app) 文件,我也不确定我是否有正确的支持文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 16
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "testproj.com.xxx.testproj"
minSdkVersion 16
targetSdkVersion 18
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:appcompat-v7:20.0.0'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:7.3.0'
compile 'com.android.volley:volley:1.0.0'
}
更新: 这是我的colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.Base">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
【问题讨论】:
-
您检查过 style.xml 文件中的 Theme.Base 吗?
-
请显示您的样式代码
标签: android android-support-library