Anim

+  alpha_anim.xml


+ rotate_anim.xml


+ scale_anim.xml




+ translate_anim.xml

+ set_anim.xml



1.Anim for layout

   Intent i = new Intent(getApplicationContext(), Main.class);
21             startActivity(i);
22             overridePendingTransition(R.anim.in, R.anim.out);
23             finish();

1 <set xmlns:android="http://schemas.android.com/apk/res/android" >
 2   <alpha
 3     android:duration="4000"
 4     android:fillAfter="true"
 5     android:fromAlpha="1.0"
 6     android:toAlpha="0.0" >
 7   </alpha>
 8
 9   <rotate
10     android:duration="3000"
11     android:fillAfter="true"
12     android:fromDegrees="0"
13     android:interpolator="@android:anim/accelerate_decelerate_interpolator"
14     android:pivotX="50%"
15     android:pivotY="50%"
16     android:toDegrees="360" >
17   </rotate>
18 </set>

1 <set xmlns:android="http://schemas.android.com/apk/res/android" >
2   <alpha
3     android:duration="3000"
4     android:fillAfter="true"
5     android:fromAlpha="0.0"
6     android:toAlpha="1.0" >
7   </alpha>
8 </set>

2.Anim for View

<set  xmlns:android=http://schemas.android.com/apk/res/android>
    <scale
        android:interpolator="@android:anim/accelerate_decelerate_interpolator"
        android:fromXScale="1.0"
        android:toXScale="1.4"
        android:fromYScale="1.0"
        android:toYScale="0.6"
        android:pivotX="50%"
        android:pivotY="50%"
        android:fillAfter="false"
        android:duration="700" />
    <set android:interpolator="@android:anim/decelerate_interpolator">
        <scale
           android:fromXScale="1.4"
           android:toXScale="0.0"
           android:fromYScale="0.6"
           android:toYScale="0.0"
           android:pivotX="50%"
           android:pivotY="50%"
           android:startOffset="700"
           android:duration="400"
           android:fillBefore="false" />
        <rotate
           android:fromDegrees="0"
           android:toDegrees="-45"
           android:toYScale="0.0"
           android:pivotX="50%"
           android:pivotY="50%"
           android:startOffset="700"
           android:duration="400" />
    </set>
</set>

ImageView spaceshipImage = (ImageView) findViewById(R.id.spaceshipImage);
Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump);
spaceshipImage.startAnimation(hyperspaceJumpAnimation);

spaceshipImage.setVisibility(View.VISIBLE);
SHARE

Nguyễn Văn Duy

  • Image
  • Image
  • Image
  • Image
  • Image

0 comments:

Post a Comment