这是我的IDE和gradle插件版本:
AndroidStudio:3.1.4
classpath 'com.android.tools.build:gradle:3.1.4'
在我的项目中,我有一个主模块和一个子模块。
在子模块中,我有一个values.xml
,如下所示:
<style name="OmActivityAnim">
<item name="android:activityOpenEnterAnimation">@anim/om_base_slide_from_right</item>
<item name="android:activityOpenExitAnimation">@anim/om_base_slide_to_left</item>
<item name="android:activityCloseEnterAnimation">@anim/om_base_slide_from_left</item>
<item name="android:activityCloseExitAnimation">@anim/om_base_slide_to_right</item>
</style>
<style name="OmActivityAnim2">
<item name="android:activityOpenEnterAnimation">@anim/om_base_show_dialog_anim</item>
<item name="android:activityOpenExitAnimation">@anim/om_base_dismiss_dialog_anim</item>
<item name="android:activityCloseEnterAnimation">@anim/om_base_show_dialog_anim</item>
<item name="android:activityCloseExitAnimation">@anim/om_base_dismiss_dialog_anim</item>
</style>
但是当我运行Main module
时,
AAPT:错误:找不到样式属性'@android:attr / activityOpenEnterAnimation'。
以下错误
error: style attribute '@android:attr/activityOpenEnterAnimation' not found.
error: style attribute '@android:attr/activityOpenExitAnimation' not found.
error: style attribute '@android:attr/activityCloseEnterAnimation' not found.
error: style attribute '@android:attr/activityCloseExitAnimation' not found.
error: style attribute '@android:attr/activityOpenEnterAnimation' not found.
error: style attribute '@android:attr/activityOpenExitAnimation' not found.
error: style attribute '@android:attr/activityCloseEnterAnimation' not found.
error: style attribute '@android:attr/activityCloseExitAnimation' not found.
但是,为什么我的android:activityOpenEnterAnimation
更改为'@android:attr/activityOpenEnterAnimation'
?
答案 0 :(得分:0)
只需在“ android”之前添加“ @”。因为“ @android”是将主题引用写到另一个资源的确切注释。
编辑您的代码
<style name="OmActivityAnim">
<item name="android:activityOpenEnterAnimation">@anim/om_base_slide_from_right</item>
<item name="android:activityOpenExitAnimation">@anim/om_base_slide_to_left</item>
<item name="android:activityCloseEnterAnimation">@anim/om_base_slide_from_left</item>
<item name="android:activityCloseExitAnimation">@anim/om_base_slide_to_right</item>
</style>
<style name="OmActivityAnim2">
<item name="android:activityOpenEnterAnimation">@anim/om_base_show_dialog_anim</item>
<item name="android:activityOpenExitAnimation">@anim/om_base_dismiss_dialog_anim</item>
<item name="android:activityCloseEnterAnimation">@anim/om_base_show_dialog_anim</item>
<item name="android:activityCloseExitAnimation">@anim/om_base_dismiss_dialog_anim</item>
</style>
到
<style name="OmActivityAnim">
<item name="@android:activityOpenEnterAnimation">@anim/om_base_slide_from_right</item>
<item name="@android:activityOpenExitAnimation">@anim/om_base_slide_to_left</item>
<item name="@android:activityCloseEnterAnimation">@anim/om_base_slide_from_left</item>
<item name="@android:activityCloseExitAnimation">@anim/om_base_slide_to_right</item>
</style>
<style name="OmActivityAnim2">
<item name="@android:activityOpenEnterAnimation">@anim/om_base_show_dialog_anim</item>
<item name="@android:activityOpenExitAnimation">@anim/om_base_dismiss_dialog_anim</item>
<item name="@android:activityCloseEnterAnimation">@anim/om_base_show_dialog_anim</item>
<item name="@android:activityCloseExitAnimation">@anim/om_base_dismiss_dialog_anim</item>
</style>
这将解决您的问题。