开发者

the animation is not work

开发者 https://www.devze.com 2023-03-09 22:04 出处:网络
i have m开发者_运维问答ade the following animation xml file in my android project: <?xml version=\"1.0\" encoding=\"utf-8\"?>

i have m开发者_运维问答ade the following animation xml file in my android project:

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

what this is basically doing is making a view dissappear starting from its center.

Now in my code i am doing the following to start the animation:

overridePendingTransition (0,R.anim,myanimation);

but nothing is happening.

what am i doing wrong?

thank you in advance.


try changing the animation to overridePendingTransition(R.anim.myanimation,0); and then set the timing accordingly if it helps. And also check this if it might help : http://developer.android.com/training/animation/cardflip.html


try this:

Animation a = AnimationUtils.loadAnimation(this, R.anim.myanimation);
myView.setAnimation(a);
a.start();


Create anim folder and paste your xml there let the name of your xml is showview Reduce your animation duration from 40seconds to see the effect for testing purpose

showview.xml

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromXScale="0.0"
    android:toXScale="1.0"
    android:fromYScale="1.0"
    android:toYScale="1.0"
    android:pivotX="100%"
    android:pivotY="100%"
    android:startOffset="0"
    android:duration="1000"
    android:fillBefore="true" /> 

In your code where you want to set animation use the following code if mImageView is the view where you want to set animation.

Animation mAnim = AnimationUtils.loadAnimation(this, R.anim.showview);
mAnim.setRepeatMode(Animation.ABSOLUTE);
mImageView.startAnimation(mAnim);

Thanks Deepak


While using animation of XML file , please check some android devices have setting:

GO to Setting --> Display --> Animation --> enable All Animation

0

精彩评论

暂无评论...
验证码 换一张
取 消