1

这是我的 IDE 和 gradle 插件版本:

安卓工作室:3.1.4

类路径'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: error: style attribute '@android:attr/activityOpenEnterAnimation' 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.    
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'

4

1 回答 1

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>

这将解决您的问题。

于 2018-09-07T06:53:25.500 回答