Imitation Zhihu Daily Launch Effect

[size=x-large]
public class MainActivity extends AppCompatActivity {
    Handler handler = new Handler ();
    private AppCompatImageView imageView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate (savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        // keep the full screen window
        //This line of code is very important, the author just missed it and didn't write the display and there was a problem
        setContentView(R.layout.welcome_layout);
        imageView = (AppCompatImageView) findViewById(R.id.welcome_image);
        welcomeImage();
    }
    private void welcomeImage(){
        imageView.setImageResource(R.drawable.wk);
        final ScaleAnimation animation = new ScaleAnimation(1.0f,1.2f,1.0f,1.2f, Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
        //The meaning of each parameter of ScaleAnimation():
        //float fromX The scaling size on the X coordinate at the beginning of the animation
         //float toX The scaling size on the X coordinate at the end of the animation
         //float fromY The scaling size on the Y coordinate at the beginning of the animation
         //float toY The scaling size on the Y coordinate at the end of the animation
         //int pivotXType animation on the X axis relative to the object position type
         //float pivotXValue The start position of the animation relative to the X coordinate of the object
         //int pivotYType animation on the Y axis relative to the object position type
         //float pivotYValue The start position of the animation relative to the object's Y coordinate
        animation.setFillAfter(true);
        animation.setDuration(4000);
        animation.setAnimationListener (new Animation.AnimationListener ()
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                Intent intent = new Intent(MainActivity.this,WelcomeActivity.class);
                startActivity(intent);
                overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
                //Imitate the fade in and out effect
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        imageView.startAnimation (animation);
    }

}
[/size]

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326632165&siteId=291194637