顺序动画XML出错



我在其中使用动画。我在使用顺序动画时遇到编译时错误。

错误为:

Multiple annotations found at this line:
    - error: No resource identifier found for attribute 'pivotX' in package 
     'android '
    - error: No resource identifier found for attribute 'fromXScale' in package 
     'android '
    - error: No resource identifier found for attribute 'toXScale' in package 
     'android '
    - error: No resource identifier found for attribute 'toYScale' in package 
     'android '
    - error: No resource identifier found for attribute 'duration' in package 
     'android '
    - error: No resource identifier found for attribute 'fromYScale' in package 
     'android '
    - error: No resource identifier found for attribute 'pivotY' in package 
     'android '

我的xml代码是:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android "
    android:fillAfter="true"
    android:interpolator="@android:anim/linear_interpolator" >
    <scale
        xmlns:android="http://schemas.android.com/apk/res/android "
        android:duration="1000"
        android:fromXScale="1"
        android:fromYScale="1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="3"
        android:toYScale="3" >
    </scale>

    <scale
        xmlns:android="http://schemas.android.com/apk/res/android "
        android:duration="1000"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="0.5"
        android:toYScale="0.5" >
    </scale>
</set>

有人能告诉我为什么会这样吗?

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" **<----- remove space**
    android:fillAfter="true"
    android:interpolator="@android:anim/linear_interpolator" >
    <scale
        xmlns:android="http://schemas.android.com/apk/res/android "
        android:duration="1000"
        android:fromXScale="1"
        android:fromYScale="1"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="3"
        android:toYScale="3" >
    </scale>

    <scale
        xmlns:android="http://schemas.android.com/apk/res/android "
        android:duration="1000"
        android:fromXScale="1.0"
        android:fromYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toXScale="0.5"
        android:toYScale="0.5" >
    </scale>

只需在的所有位置替换下线

xmlns:android="http://schemas.android.com/apk/res/android "

带有

xmlns:android="http://schemas.android.com/apk/res/android"

末尾有多余的空白。

编辑:对于AnimationListener

将此写入onWindowFocusChanged()

Animation anim_translate = AnimationUtils.loadAnimation(
                    HomeScreenActivity.this, R.anim.translate);
img_main.startAnimation(anim_translate);
anim_translate.setAnimationListener(new AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                }
                @Override
                public void onAnimationRepeat(Animation animation) {
                }
                @Override
                public void onAnimationEnd(Animation animation) {
                    // start another activity
                }
            });

相关内容

最新更新