zoom out animation in splash screen in android?

后端 未结 2 1389
傲寒
傲寒 2021-02-06 15:06

I have a requirement in which i have to give zoom out effect in splash screen. Please Suggest something. I have an idea that we can keep its animation in res/anim folder and use

相关标签:
2条回答
  • 2021-02-06 16:02

    Use this in Activity Java File :

    FrameLayout mainFrame = ((FrameLayout) findViewById(R.id.FrameLayout01));
            Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(this,
                    R.anim.hyperspace_jump);
            mainFrame.startAnimation(hyperspaceJumpAnimation);
    

    Put this code under res > anim > hyperspace_jump.xml

    <?xml version="1.0" encoding="UTF-8"?>
    
    <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false">
       <scale
              android:interpolator="@android:anim/accelerate_decelerate_interpolator"
              android:fromXScale="0.0"
              android:toXScale="1.4"
              android:fromYScale="0.0"
              android:toYScale="1.4"
              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.8"
                 android:fromYScale="1.4"
                 android:toYScale="0.8" 
                 android:pivotX="50%" 
                 android:pivotY="50%" 
                 android:startOffset="700"
                 android:duration="400" 
                 android:fillBefore="false" />
          <!-- <rotate 
                 android:fromDegrees="0" 
                 android:toDegrees="360"
                 android:toYScale="0.0" 
                 android:pivotX="50%" 
                 android:pivotY="50%"
                 android:startOffset="700"
                 android:duration="400" />
              -->
       </set>
    </set>
    
    0 讨论(0)
  • 2021-02-06 16:06

    yu can use the view animation in order to get the zoom effect.

    <set xmlns:android="http://schemas.android.com/apk/res/android"
        android:shareInterpolator="false">
       <alpha android:fromAlpha="0.0"
            android:toAlpha="1.0" android:duration="900">        
       </alpha>
        <set
            android:interpolator="@android:anim/accelerate_interpolator"
            android:startOffset="700">
         <scale
                android:fromXScale="0"
                android:toXScale="1"
                android:fromYScale="0"
                android:toYScale="1.0"
                android:pivotX="50%"
                android:pivotY="50%"
                android:duration="1000" 
               android:fillBefore="false"   
          />
       </set>
    </set>
    

    create an XML file in the animation folder under resource.And in the java file you must set the animation for the respective image.

    Animation hyperspaceJump = AnimationUtils.loadAnimation(this, R.anim.hyperspace_jump);
    image.startAnimation(hyperspaceJump);
    

    Here my xml file name is hyperspace_jump.for more reference click here.

    0 讨论(0)
提交回复
热议问题