我从Android的Color Tool设计了我的颜色文件,并从那里导出了相同的颜色文件。但是当我用现有文件替换文件时。
Information:Gradle tasks [:app:assembleDebug]
C:\Users\LENOVO\.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\fe9fe9aedd60d1d8fd516975c2138d20\res\values\values.xml
Error:error: style attribute 'attr/colorPrimaryLight (aka com.example.lenovo.jdstudio:attr/colorPrimaryLight)' not found.
Error:error: style attribute 'attr/colorSecondary (aka com.example.lenovo.jdstudio:attr/colorSecondary)' not found.
Error:error: style attribute 'attr/colorSecondaryLight (aka com.example.lenovo.jdstudio:attr/colorSecondaryLight)' not found.
Error:error: style attribute 'attr/colorSecondaryDark (aka com.example.lenovo.jdstudio:attr/colorSecondaryDark)' not found.
Error:error: style attribute 'attr/primaryTextColor (aka com.example.lenovo.jdstudio:attr/primaryTextColor)' not found.
Error:error: style attribute 'attr/secondaryTextColor (aka com.example.lenovo.jdstudio:attr/secondaryTextColor)' not found.
F:\JDStudio\code\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Error:(1899) style attribute 'attr/colorPrimaryLight (aka com.example.lenovo.jdstudio:attr/colorPrimaryLight)' not found.
Error:(1901) style attribute 'attr/colorSecondary (aka com.example.lenovo.jdstudio:attr/colorSecondary)' not found.
Error:(1902) style attribute 'attr/colorSecondaryLight (aka com.example.lenovo.jdstudio:attr/colorSecondaryLight)' not found.
Error:(1903) style attribute 'attr/colorSecondaryDark (aka com.example.lenovo.jdstudio:attr/colorSecondaryDark)' not found.
Error:(1904) style attribute 'attr/primaryTextColor (aka com.example.lenovo.jdstudio:attr/primaryTextColor)' not found.
Error:(1905) style attribute 'attr/secondaryTextColor (aka com.example.lenovo.jdstudio:attr/secondaryTextColor)' not found.
Error:failed linking references.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 57s
Information:17 errors
Information:0 warnings
Information:See complete output in console
<?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="content">#F5F5F5</color>>
</resources>
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<color name="colorPrimary">#0091ea</color>
<color name="colorPrimaryLight">#64c1ff</color>
<color name="colorPrimaryDark">#0064b7</color>
<color name="colorSecondary">#263238</color>
<color name="colorSecondaryLight">#4f5b62</color>
<color name="colorSecondaryDark">#000a12</color>
<color name="primaryTextColor">#fafafa</color>
<color name="secondaryTextColor">#ffffff</color>
</resources>
<resources>
<!-- Base application theme. -->
<style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryLight">@color/colorPrimaryLight</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorSecondary">@color/colorSecondary</item>
<item name="colorSecondaryLight">@color/colorSecondaryLight</item>
<item name="colorSecondaryDark">@color/colorSecondaryDark</item>
<item name="primaryTextColor">@color/primaryTextColor</item>
<item name="secondaryTextColor">@color/secondaryTextColor</item>
</style>
</resources>
android:theme="@style/MyAppTheme"
答案 0 :(得分:0)
您需要将此行放在 colors.xml
中<color name="colorAccent">#FF4081</color>
或者你需要在style.xml中将另一种颜色作为强调颜色。
<style name="AppTheme_Light" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/abc1</item>
<item name="colorPrimaryDark">@color/abc2</item>
<item name="colorAccent">@color/abc3</item>
</style>
快乐编码:)
答案 1 :(得分:0)
我认为你可以使用android studio样式编辑器。它更简单并自动改变您的颜色。 您应该在 style.xml 中定义样式,并在 color.xml 中定义颜色 并且不要用原始文件替换文件,否则可能会出现很多错误。