This article describes the effect of Android development rewriting Animation to achieve the pull-down image and ejecting it back. Share it for your reference, as follows:
1. Analysis:
1)interpolatedTimeRefers to the rate of change of translation (from 0 to 1)
2)mStartHeight The height at which the control starts
3)endHeight The height of the control after vertical movement
4)();The image fills the layout and fixes after changing the height
5)(interpolatedTime, mStartHeight, mEndHeight) + 0.5f)Get the height after changing
2. Code:
/** * @Description Use flat-moving painting to implement the image and then eject it back * @Project name App_imooc * @Bank Name * @Class Name ResetAnimation * @author chenlin * @date May 29, 2015 12:27:00 pm * @version 1.0 */ public class ResetAnimation extends Animation { private ImageView mImageView; private int mStartHeight; private int mEndHeight; public ResetAnimation(ImageView imageView, int startHeight, int endHeight) { = imageView; = startHeight; = endHeight; setDuration(500); } @Override protected void applyTransformation(float interpolatedTime, Transformation t) { int newHeight = (int) ((interpolatedTime, mStartHeight, mEndHeight) + 0.5f); ().height = newHeight; (); (interpolatedTime, t); } }
3. How to use:
// Vertical Move AnimationResetAnimation anim = new ResetAnimation(mImageView, startHeight, endHeight); (new OvershootInterpolator()); startAnimation(anim);
For more information about Android related content, please check out the topic of this site:Android development animation skills summary》、《Android development introduction and advanced tutorial》、《Android View View Tips Summary》、《Android programming activity operation skills summary》、《Android file operation skills summary》、《Android resource operation skills summary"and"Android control usage summary》
I hope this article will be helpful to everyone's Android programming design.