找不到与android:colorForegroundInverse中的值匹配的资源@ color/foreground_material_light
问题描述:
我想通过覆盖主题来更改应用程序中的颜色。我有几个用户可以选择的主题。我在Android Studio中试图重写主题时,得到这个错误:找不到与android:colorForegroundInverse中的值匹配的资源@ color/foreground_material_light
没有资源发现,在Android的给定名称匹配:colorForegroundInverse /值为@色foreground_material_light
值\ styles.xml
<resources>
<style name="LigthTheme" parent="@style/Theme.AppCompat">
<!-- <item name="colorPrimary">@color/aztec_gold</item>
<item name="colorPrimaryDark">@color/licorice</item>
<item name="colorAccent">@color/accent_material_light</item>
<item name="android:itemBackground">@color/aztec_gold</item>
<item name="android:background">@color/aztec_gold</item>
-->
</style>
<style name="RetroTheme" parent="@style/Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">@color/nickel</item>
<item name="colorPrimary">@color/spanish_gray</item>
<item name="colorAccent">@color/turtle_green</item>
<item name="android:windowBackground">@color/white_smoke</item>
<item name="android:colorBackground">@color/white_smoke</item>
<item name="android:textColorPrimary">@color/black</item>
<item name="android:textColorSecondary">@color/black_light</item>
<item name="android:textColorSecondaryInverse">@color/white</item>
<item name="android:textColorPrimaryInverse">@color/white_smoke</item>
<item name="android:colorForeground">@color/white_smoke</item>
<item name="colorButtonNormal">@color/june_bud</item>
<item name="android:colorForegroundInverse">@color/white_smoke</item>
</style>
<style name="DarkTheme" parent="@style/Theme.AppCompat">
<!-- <item name="colorPrimary">@color/aztec_gold</item>
<item name="colorPrimaryDark">@color/licorice</item>
<item name="colorAccent">@color/accent_material_light</item>
<item name="android:itemBackground">@color/aztec_gold</item>
<item name="android:background">@color/aztec_gold</item>
-->
</style>
值\ colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="spanish_gray">#9e9e9e</color>
<color name="pastel_gray">#cfcfcf</color>
<color name="nickel">#707070</color>
<color name="june_bud">#aed851</color>
<color name="pale_goldenrod">#e1ffb1</color>
<color name="turtle_green">#7da453</color>
<color name="white_smoke">#f5f5f5</color>
<color name="black">#d2000000</color>
<color name="black_light">#9c000000</color>
<color name="black_light1">#9c000000</color>
<color name="white">#ffffff</color>
</resources>
的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.ivan.vts.mapper"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "2048M"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile group: 'com.google.code.gson', name: 'gson', version: '2.4'
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.google.android.gms:play-services-location:10.2.4'
compile 'com.google.android.gms:play-services-maps:10.2.4'
compile 'com.google.android.gms:play-services-places:10.2.4'
compile 'com.android.support:multidex:1.0.1'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.maps.android:android-maps-utils:0.4.+'
testCompile 'junit:junit:4.12'
}
试图把colorForegroundInverse和foreground_material_light在styles.xml,colors.xml,设置家长不同的主题BT总是相同的错误。 在此先感谢。
编辑: 我可以colors.xml像添加: <color name="foreground_material_light">#fff</color>
并有警告,但没有错误。我感觉不舒服。
答
您可以尝试访问颜色 @android:color/foreground_material_light
不能访问,因为不存在了。所以我会更新我的问题。 – Chiefster
在你的gradle依赖中加入'compile'com.android.support:appcompat-v7:25.0.1'' – VishnuSP
我会在下班回家时试试,谢谢 – Chiefster