详情:
error: style attribute 'attr/colorTextGreen (aka com.example.a92317.ltka:attr/colorTextGreen)' not found. Message{kind=ERROR, text=error: style attribute 'attr/colorTextGreen (aka com.example.a92317.ltka:attr/colorTextGreen)' not found., sources=[C:\Users\92317.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.0.2.aar\42626cc3773e81f375f5215b1d4a6d01\res\values\values.xml:391:5-397:13], original message=, tool name=Optional.of(AAPT)}
颜色.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorTextGreen">#006600</color>
<color name="colorBackgroundGreen">#F0F8FF</color>
<color name="colorTransparent">#00000000</color>
</resources>
样式.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorTextGreen">@color/colorTextGreen</item>
<item name="colorBackgroundGreen">@color/colorBackgroundGreen</item>
<item name="colorTransparent">@color/colorTransparent</item>
</style>
<style name="FontStyle" parent="AppTheme">
<item name="android:fontFamily">@font/newfont</item>
</style>
</resources>
我该如何解决这个问题? 我快死了...
最佳答案
以下不是有效的项目名称
<item name="colorTextGreen">@color/colorTextGreen</item>
您只能使用在 xml 布局中指定属性的项目名称。元素中的值是该属性的值。
示例
<item name="android:background">@color/colorTextGreen</item>
这将是默认背景颜色,因为我们将项目名称设置为主题颜色。
关于Android Studio - 找不到颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50725399/