Android TranslateAnimation - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android TranslateAnimation class.

This code example shows how to use the following methods:setAnimationListener, setDuration, setFillBefore, setFillEnabled, setInterpolator
This code example shows how to use the following methods:setAnimationListener, setDuration, setInterpolator
      anim=new TranslateAnimation(0.0f, 0.0f,
                                  getHeight(),
                                  0.0f); 
    } 
    else { 
      anim=new TranslateAnimation(0.0f, 0.0f, 0.0f,
                                  getHeight());
      anim.setAnimationListener(collapseListener);
    } 
     
    anim.setDuration(speed);
    anim.setInterpolator(new AccelerateInterpolator(1.0f));
    startAnimation(anim);
  } 
   
  Animation.AnimationListener collapseListener=new Animation.AnimationListener() {
    public void onAnimationEnd(Animation animation) { 
      setVisibility(View.INVISIBLE); 
    } 
     
8
CodeRank
This code example shows how to use the following methods:
@Implements(AnimationUtils.class) 
public class ShadowAnimationUtils { 
 
  @Implementation 
  public static Animation loadAnimation(Context context, int id) { 
    Animation anim = new TranslateAnimation(0, 0, 30, 0); 
    Robolectric.shadowOf(anim).setLoadedFromResourceId(id); 
    return anim; 
  } 
 
  @Implementation 
  public static Interpolator loadInterpolator(Context context, int id) { 
    return new LinearInterpolator(); 
  } 
 
  @Implementation 
  public static LayoutAnimationController loadLayoutAnimation(Context context, int id) { 
    Animation anim = new TranslateAnimation(0, 0, 30, 0); 
    LayoutAnimationController layoutAnim = new LayoutAnimationController(anim); 
    Robolectric.shadowOf(layoutAnim).setLoadedFromResourceId(id); 
8
CodeRank
This code example shows how to use the following methods:
	 
	 
	@Test 
	public void testAnimationList() { 
		Animation alpha = new AlphaAnimation(1f, 2f);
		Animation translate =  new TranslateAnimation(1f, 2f, 3f, 4f);
		Animation rotate = new RotateAnimation(1f, 2f);
		set.addAnimation(alpha);
		set.addAnimation(translate);
		set.addAnimation(rotate);
		 
		List<Animation> list = shadow.getAnimations();
        assertThat(list.size()).isEqualTo(3);
        assertThat(list.get(0)).isSameAs(alpha);
        assertThat(list.get(1)).isSameAs(translate);
        assertThat(list.get(2)).isSameAs(rotate);
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:setAnimationListener, setDuration
	            break; 
	        case BOTTOM:
	            y=getHeight();
	            break; 
		}		 
		TranslateAnimation anim=new TranslateAnimation(0, x, 0,y);
		anim.setDuration(ANIM_DURATION);
		anim.setAnimationListener(new AnimationListener() {
			 
			//@Override 
			public void onAnimationStart(Animation animation) {
				// TODO Auto-generated method stub 
			} 
			 
			//@Override 
			public void onAnimationRepeat(Animation animation) {
				// TODO Auto-generated method stub 
			} 
			 
			//@Override 
7
CodeRank
This code example shows how to use the following methods:setDuration, setFillAfter
			return null; 
		} 
 
		int dx = getLeft() - old_x;
		int dy = getTop() - old_y;
		Animation a = new TranslateAnimation(-dx, 0, -dy, 0);
		a.setFillAfter(true);
		a.setDuration(durationMillis);
 
		old_x = getLeft();
		old_y = getTop();
 
		return a;
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:setAnimationListener, setDuration, setFillBefore, setFillEnabled, setInterpolator
This code example shows how to use the following methods:setDuration, setInterpolator
    	outtoLeft.setInterpolator(new AccelerateInterpolator());
    	return outtoLeft;
    } 
 
    public static Animation inFromLeftAnimation() {
    	Animation inFromLeft = new TranslateAnimation(
    			Animation.RELATIVE_TO_PARENT,  -1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
    			Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
    	); 
    	inFromLeft.setDuration(DURATION);
    	inFromLeft.setInterpolator(new AccelerateInterpolator());
    	return inFromLeft;
    } 
     
    public static Animation outToRightAnimation() {
    	Animation outtoRight = new TranslateAnimation(
    			Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  +1.0f,
    			Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
    	); 
    	outtoRight.setDuration(DURATION);
7
CodeRank
This code example shows how to use the following methods:setAnimationListener, setDuration
    } 
 
    @Override 
    public void onSizeChanged(int w, int h, int oldW, int oldH) {
        mWidth = w;
        inLeft   = new TranslateAnimation(mWidth, 0, 0, 0);
        inLeft.setAnimationListener(this);
        outLeft  = new TranslateAnimation(0, -mWidth, 0, 0);
        inRight  = new TranslateAnimation(-mWidth, 0, 0, 0);
        inRight.setAnimationListener(this);
        outRight = new TranslateAnimation(0, mWidth, 0, 0);
 
        inLeft.setDuration(ANIM_DURATION);
        outLeft.setDuration(ANIM_DURATION);
        inRight.setDuration(ANIM_DURATION);
        outRight.setDuration(ANIM_DURATION);
    } 
 
    @Override 
    protected void onFinishInflate() { 
7
CodeRank
This code example shows how to use the following methods:setAnimationListener
      anim=new TranslateAnimation(0.0f, 0.0f,
                                  getHeight(),
                                  0.0f); 
    } 
    else { 
      anim=new TranslateAnimation(0.0f, 0.0f, 0.0f,
                                  getHeight());
      anim.setAnimationListener(collapseListener);
      set.addAnimation(fadeOut);
    } 
     
    set.addAnimation(anim);
    set.setDuration(speed);
    set.setInterpolator(new AccelerateInterpolator(1.0f));
    startAnimation(set);
  } 
   
  Animation.AnimationListener collapseListener=new Animation.AnimationListener() {
    public void onAnimationEnd(Animation animation) { 
      setVisibility(View.INVISIBLE); 
7
CodeRank

Related Android TranslateAnimation Questions & Answers:

See Code Examples for Android TranslateAnimation Methods: