DevBytes: View Animations
Why Stack Overflow recommends it
Stack Overflow users link it when answering Android animation questions, as a quick walkthrough of translate, scale and rotate view animations and how they differ from property animations.
Recommended by 5 people across 6 different months, 2013 to 2015.
What it is
A short DevBytes episode from the Android Developers channel (presented by Chet Haase) showing how to use the pre-3.0 View Animation classes such as TranslateAnimation, ScaleAnimation and RotateAnimation to build animated UI effects. It comes with a downloadable demo and points to a companion demo using the newer ObjectAnimator API.
What people said
Recommends Wenger · 2013-01 · Stack Overflow · on “Android Loading Indicator for Downloading Images”
You could try doing a View Animation [LINK] on the ImageView. Rotate is one of the included animations, and you can define it in XML. Here's a [this video] from Google explaining it a little more.
Recommends Leandros · 2013-02 · Stack Overflow · on “Apply one animation to multiple views at the same time”
Try to use the new Animation API (for backwards compatability use NineOldAndroids). Also I recommend to watch this: [this video]
Recommends Dmytro Danylyk · 2013-04 · Stack Overflow · on “Fill screen with ImageView on tap”
If you want to zoom in/out view you can use scale animation. I recommend to watch Chet Haase tutorials called DevBytes: View Animations [this video]
Recommends Ondřej Z · 2013-07 · Stack Overflow · on “How to refresh Button in RelativeLayout”
What about this: number1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { number1.startAnimation(animBounce); } }); EDIT: Quick tutorial on Android animations: [this video]
Recommends A Honey Bustard · 2015-02 · Stack Overflow · on “Adding views to FrameLayout and animating them”
Check this video, this shows easy examples of different animations which can be applied to most Views : [this video] Name of the video : DevBytes View Animations for example for moving around a button use a TranslateAnimation : TranslateAnimation myTranslateAnimation = new TranslateAnimation(fromX, toX, fromY, toY); // fill in your coordinates from where, to where you want to move it myTranslateAnimation.setDuration(1000); // Animation plays for 1 sec myImageButton.startAnimation(myTranslateAnimation);
Recommends A Honey Bustard · 2015-03 · Stack Overflow · on “ObjectAnimator vs TranslateAnimation”
The difference is mainly that if you use a TranslateAnimation, the view which you are animating does not really leave its original position on the screen, it just makes it look like it is moving. So the view basically doesnt change its coordinates. Check this video about View Animations : [this video] If you use an ObjectAnimator the view really changes its actual position. TranslateAnimation is not deprecated, you can still find it on Lollipop, but for most cases I can recommend a class called ViewPropertyAnimator [LINK] , which many people still dont seem to know about, it is probably the easiest and most straight forward way to animate a view, and can also save you a lot of code. Heres an exam
Cites Xaver Kapeller · 2014-06 · Stack Overflow · on “How to define a screen-size specific animation in XML”
1) Regarding the bounty: Existing answers on SO [LINK] suggest subclassing the FrameLayout... If you want to use an ObjectAnimator you have no choice but to subclass the View you want to animate. You need to provide the ObjectAnimator with the necessary getter and setter methods to do its magic as it essentially just calls those getter and setter methods to perform the Animation . The question you are linking to ( Animate the transition between fragments [LINK] ) is subclassing FrameLayout to add a setXFraction() and a getXFraction() method. They are implemented in a way to set the x value relative to the width of the FrameLayout . Only by doing this can the ObjectAnimator do anything else b
Cites Damian Petla · 2014-08 · Stack Overflow · on “How to refresh layout after animation in android?”
Inside onAnimationEnd() you have to update your layout parameters of the view which you are animating, in your case it's LinearLayout. You have to update view in respect of the parent. If your animated view parent is e.g. RelativeLayout you can call this: RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) animatedView.getLayoutParams(); //TODO modify params animatedView.setLayoutParams(params); animatedView.requestLayout(); I think this should work. You can also try calling requestLayout() on the parent. There is also tutorial on YT [this video] about View animations. Chet Haase talks about handling animations including TranslateAnimation . I don't have time to watch but maybe you