顺序动画XML中的错误

时间:2014-04-18 04:54:17

标签: android xml animation

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

错误是:

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>

谁能告诉我为什么会这样?

2 个答案:

答案 0 :(得分:3)

<?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>

答案 1 :(得分:1)

到处替换下面的行

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
                }
            });