this article describes the example code of Java for frame animation.

1, effect diagram

< > > sketch, frame animation brief code

 private ImageView bgAnimView; private AnimationDrawable mAnimationDrawable; / / / / / / / / initialization mAnimationDrawable = new AnimationDrawable (); bgAnimView = new. Rams (ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.topMargin = Util.Div (176 + 58); params.gravity = Gravity.CENTER_HORIZONTAL; addView (bgAnimView, params); private AnimationDrawable. N = 50; mAnimationDrawable.addFrame (mContext.getResources ().GetDrawable (R.drawable.loading1), duration); mAnimationDrawable.addFrame (mContext.getResources ().GetDrawable (R.drawable.loading2), duration); mAnimationDrawable.addFrame. Ion); mAnimationDrawable.setOneShot (false); return mAnimationDrawable;} / / / / / / / animation begins with public void animLoadingStart () {this.setVisibility (View.VISIBLE); if (mAnimationDrawable! = =);}} / / / animation ends {} {} NimationDrawable! = null) {mAnimationDrawable.stop ();} 

3, extension:

 //X axis translates public void animY. (yourView, "translationY", 0, 300); if //300 is negative, it is the upward translation of animator.setDuration (duration); animator.setInterpolator (LL); animator.start ();} //Y axis translates public void animX. R animator = ObjectAnimator.ofFloat (yourView, "translationX", x, nextX); animator.setDuration (duration); animator.setInterpolator (LL); animator.start ();} / / / / / longitudinal compression 0.5 times equal. 1, 1, 0.5f); / / / / / / default from (0,0) scaleAnimation.setDuration (500); scaleAnimation.setInterpolator (LL); scaleAnimation.setFillAfter (true); chartView.startAnimation (scaleAnimation); / / / / / / lateral compression LinearInterpolator ll = new = W ScaleAnimation (1, 0.5f, 1, 1); / / / / default from (0,0) scaleAnimation.setDuration (500); scaleAnimation.setInterpolator (LL); scaleAnimation.setFillAfter (true); chartView.startAnimation (scaleAnimation); 

> open material download address above is this All the contents of the article, I hope that the content of this article for everyone's learning or work has a certain reference value, if there is a doubt that people can leave a message and exchange, thank you for the support of the script home.

This paper fixed link:http://www.script-home.com/java-instance-code-for-frame-animation.html | Script Home | +Copy Link

Article reprint please specify:Java instance code for frame animation | Script Home

You may also be interested in these articles!