Android View sliding animation, androidview
[ScrollTo/scrollBy]
// The text in the control will move, but the control itself will not move. After moving outside the control, the text will not be visible.
If (v. equals (button2 )){
Button2.scrollTo (5, 5); // The text in the View will move 5 to the left, 5 to the top, and the absolute coordinate will only move once
Toast. makeText (this, "User Name", Toast. LENGTH_SHORT). show ();
} Else if (v. equals (button3 )){
Button3.scrollBy (5, 5); // The text in the View will move 5 to the left, 5 to the top, and the relative coordinates will be moved countless times
Toast. makeText (this, "use", Toast. LENGTH_SHORT). show ();
}
[Animation]
// Fill room animation // The original seat will not be occupied
// Controls A can be moved, and controls can be stuck at the Moving End Point through fillAfter
// But the focus is actually in the original place, moving from other places to the original place A (when moving control A can get the Focus) control A will return from the stop
// (When the moving control A cannot obtain the focus) if it moves to the original place A, control A will stay at the moving end point.
Animation animation2 = AnimationUtils. loadAnimation (getApplicationContext (), R. anim. slide_big_in_right );
Button2.startAnimation (animation2 );
<? Xml version = "1.0" encoding = "UTF-8"?>
<Set xmlns: android = "http://schemas.android.com/apk/res/android"
Android: fillAfter = "true">
<Translate
Android: fromxdel= "1920"
Android: toXDelta = "1000"
Android: fromYDelta = "0"
Android: toYDelta = "0"
Android: duration= "2000"
Android: interpolator = "@ android: anim/decelerate_interpolator"/>
</Set>
// The animation condition of the compensation room is the same as that above. // In fact, the focus is still in the original place.
TranslateAnimation animation = new TranslateAnimation (0, 0 );
Animation. setDuration (2000); // sets the animation duration.
Animation. setRepeatCount (2); // you can specify the number of repetitions.
Animation. setFillAfter (true );
Animation. setRepeatMode (Animation. REVERSE); // sets the REVERSE direction for execution.
Button4.startAnimation (animation );
// Property animation // The original seat will not be occupied
// The entire control moves 100 to the right and stays at the end and the focus is at the end. Even if you click this control, it is still at the end
ObjectAnimator. ofFloat (button2, "translationX", 0,100)
. SetDuration (100). start ();
[Change layout parameters]
// The entire control is moved, and the focus is also moved. The original location will be occupied,
RelativeLayout. LayoutParams mParams = (RelativeLayout. LayoutParams) button3.getLayoutParams ();
MParams. width = 100;
MParams. height = 130;
MParams. setMargins (50, 50, 0, 0 );
Button3.setLayoutParams (mParams );
Button3.setPadding (20, 0, 0, 0 );