Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=====================================================
- public class SlideFromRightAnimation {
- private float end = 0, start=0;
- private int duration = 3300;
- private TimeInterpolator interpolator = new AccelerateInterpolator();
- //===================================
- public SlideFromRightAnimation(Activity act, int duration){
- if(android.os.Build.VERSION.SDK_INT>=13){
- Point p = new Point();
- act.getWindowManager().getDefaultDisplay().getSize(p);
- start = p.x;
- }else{
- DisplayMetrics d = new DisplayMetrics();
- act.getWindowManager().getDefaultDisplay().getMetrics(d);
- start = d.widthPixels;
- }
- this.duration = duration;
- }
- //===================================
- public void setInterpolator(TimeInterpolator ip){interpolator=ip;}
- //===================================
- public ValueAnimator getAnimator(View v){
- ValueAnimator anim = ObjectAnimator.ofFloat(v, "translationX", start,end);
- anim.setInterpolator(interpolator);
- anim.setDuration(duration);
- return anim;
- }
- //===================================
- public void start(View v){
- ValueAnimator anim = getAnimator(v);
- anim.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement