Android AnimationSet - 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 AnimationSet class.

This code example shows how to use the following methods:setInterpolator, addAnimation, setDuration
    fadeOut=AnimationUtils.loadAnimation(ctxt, R.anim.fade);
  } 
   
  public void toggle() { 
    TranslateAnimation anim=null;
    AnimationSet set=new AnimationSet(true);
     
    isOpen=!isOpen;
     
    if (isOpen) {
      setVisibility(View.VISIBLE);
      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);

9
CodeRank
This code example shows how to use the following methods:setFillEnabled, addAnimation, setFillAfter
This code example shows how to use the following methods:addAnimation, setFillAfter
7
CodeRank
This code example shows how to use the following methods:setFillEnabled, addAnimation, setFillAfter
View v = getChildAt(dragged);
    	int x = getCoorFromIndex(dragged).x + childSize / 2, y = getCoorFromIndex(dragged).y + childSize / 2;
        int l = x - (3 * childSize / 4), t = y - (3 * childSize / 4);
    	v.layout(l, t, l + (childSize * 3 / 2), t + (childSize * 3 / 2));
    	AnimationSet animSet = new AnimationSet(true);
		ScaleAnimation scale = new ScaleAnimation(.667f, 1, .667f, 1, childSize * 3 / 4, childSize * 3 / 4);
		scale.setDuration(animT);
		AlphaAnimation alpha = new AlphaAnimation(1, .5f);
		alpha.setDuration(animT);
 
		animSet.addAnimation(scale);
		animSet.addAnimation(alpha);
		animSet.setFillEnabled(true);
		animSet.setFillAfter(true);
		 
		v.clearAnimation();
		v.startAnimation(animSet);
    } 
    protected void animateGap(int target)
7
CodeRank
This code example shows how to use the following methods:setRepeatCount, addAnimation, setRepeatMode
  /* 
   * Animates a component moving it horizontally. 
   */ 
  private static void ApplyHorizontalScrollAnimation(View view, boolean left, int speed) {
    float sign = left ? 1f : -1f;
    AnimationSet animationSet = new AnimationSet(true);
    animationSet.setRepeatCount(Animation.INFINITE);
    animationSet.setRepeatMode(Animation.RESTART);
 
    TranslateAnimation move = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, sign * 0.70f,
        Animation.RELATIVE_TO_PARENT, sign * -0.70f, Animation.RELATIVE_TO_PARENT, 0,
        Animation.RELATIVE_TO_PARENT, 0);
    move.setStartOffset(0);
    move.setDuration(speed);
    move.setFillAfter(true);
    animationSet.addAnimation(move);
    view.startAnimation(animationSet);
  } 
 
  /** 
   * Animates a component (using pre-defined animation kinds). 
7
CodeRank
This code example shows how to use the following methods:addAnimation
7
CodeRank
This code example shows how to use the following methods:addAnimation, setDuration
        mImageView = (ImageView)findViewById(R.id.image);
        mImageView.setImageResource(R.drawable.sample);
    } 
 
    public void startMix(View view) {
        AnimationSet animation = new AnimationSet(true);
        // 透明になりながら 
        animation.addAnimation(new AlphaAnimation(1.0F, 0.0F));
        // 回転しながら 
        animation.addAnimation(new RotateAnimation(0, 360));
        // 拡大しながら 
        animation.addAnimation(new ScaleAnimation(1, 2, 1, 2));
        // 移動しながら 
        animation.addAnimation(new TranslateAnimation(0, 300, 0, 300));
        // 3秒で 
        animation.setDuration(3000);
        mImageView.startAnimation(animation);
    } 
 
    public void startAlpha(View view) {
        AlphaAnimation animation;
7
CodeRank
This code example shows how to use the following methods:addAnimation
	@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:setAnimation, setAnimationListener, startNow, addAnimation, setDuration
			anim.setDuration(500);
			anim.startNow();
		} else if (!visible && mStates[menu] != STATE_OUT) {
			mStates[menu] = STATE_OUT;
 
			AnimationSet anim = new AnimationSet(true);
			anim.addAnimation(new AlphaAnimation(1f, 0f));
			if (fadeRight) {
				anim.addAnimation(new TranslateAnimation(0f, 100f, 0f, 0f));
			} else { 
				anim.addAnimation(new TranslateAnimation(0f, -100f, 0f, 0f));
			} 
 
			mMenus[menu].setAnimation(anim);
			anim.setDuration(500);
			anim.setAnimationListener(new Animation.AnimationListener() {
				@Override 
				public void onAnimationEnd(Animation anim) {
					mMenus[menu].setVisibility(View.GONE);
				} 

7
CodeRank
This code example shows how to use the following methods:
    public AnimationHelper(Context context) {
        this.context = context.getApplicationContext();
    } 
 
    public Animation loadAnimation(int animationRes) {
        return animationRes == ANIMATION_DISABLED ? new AnimationSet(false) : AnimationUtils.loadAnimation(context, animationRes);
    } 
} 
6
CodeRank

Related Android AnimationSet Questions & Answers:

See Code Examples for Android AnimationSet Methods: