在 Intellij 中创建新的 Android 项目:默认情况下缺少 res/values/* xml - 手动添加不起作用
Creating new Android project in Intellij: Missing res/values/* xml's by default-Manual add not working
当我在 Intellij 14 中创建新的 Android 项目时,我只有 strings.xml 而没有:colors.xml、styles.xml
这是为什么?
当我手动添加 styles.xml 时:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- customize the color palette -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
和colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="colorPrimary" type="color">#03A9F4</item>
<item name="colorPrimaryDark" type="color">#0288D1</item>
<item name="colorAccent" type="color">#ECEFF1</item>
</resources>
然后尝试在清单上应用主题:
<application ...
android:theme="@styles/Theme.MyTheme">
我收到以下错误:
Error:Android Resource Packaging: No resource found that matches the given name (at 'theme' with value '@styles/Theme.MyTheme').
如何解决?我的目标是使用 API>16(我正在使用 appcompat V7 作为依赖库项目)使 material 设计具有原色、深色等颜色。
谢谢,
声明颜色资源的正确方法是这样的:
<color name="colorPrimary">#03A9F4</color>
在清单上尝试下一个代码:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MyTheme">
@style 不是@styles
当我在 Intellij 14 中创建新的 Android 项目时,我只有 strings.xml 而没有:colors.xml、styles.xml
这是为什么?
当我手动添加 styles.xml 时:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">
<!-- customize the color palette -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
和colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="colorPrimary" type="color">#03A9F4</item>
<item name="colorPrimaryDark" type="color">#0288D1</item>
<item name="colorAccent" type="color">#ECEFF1</item>
</resources>
然后尝试在清单上应用主题:
<application ...
android:theme="@styles/Theme.MyTheme">
我收到以下错误:
Error:Android Resource Packaging: No resource found that matches the given name (at 'theme' with value '@styles/Theme.MyTheme').
如何解决?我的目标是使用 API>16(我正在使用 appcompat V7 作为依赖库项目)使 material 设计具有原色、深色等颜色。
谢谢,
声明颜色资源的正确方法是这样的:
<color name="colorPrimary">#03A9F4</color>
在清单上尝试下一个代码:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.MyTheme">
@style 不是@styles