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

This code example shows how to use the following methods:getDuration, getNumberOfFrames, start
	} 
 
	@Override 
	public void onWindowFocusChanged(boolean hasFocus) {
	  if (hasFocus && mAnimation != null) {
		  mAnimation.start();
		  mKillActivityHandler.sleep(mAnimation.getDuration(0) * mAnimation.getNumberOfFrames());
	  } 
	} 
	 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:start
            mAnim.stop();
        } 
        if (drawable instanceof AnimationDrawable) {
            mAnim = (AnimationDrawable)drawable;
            if (isShown()) {
                mAnim.start();
            } 
        } else { 
            mAnim = null;
        } 
    } 
 
    @Override 
    public void setImageDrawable(Drawable drawable) {
        super.setImageDrawable(drawable);
        updateAnim(); 
    } 
 
    @Override 
    @android.view.RemotableViewMethod 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isRunning, stop
        // When the user clicks on the image, toggle the animation on/off 
        imageview.setOnClickListener(new View.OnClickListener() {
 
            @Override 
            public void onClick(View v) {
                if (animationDrawable.isRunning()) {
                    animationDrawable.stop();
                } else { 
                    animationDrawable.start();
                } 
            } 
        }); 
    } 
 
    /** 
     * The 'frames' in this app are nothing more than a gray background with text indicating 
     * the number of the frame. 
     */ 
    private BitmapDrawable getDrawableForFrameNumber(int frameNumber) {
        Bitmap bitmap = Bitmap.createBitmap(400, 400, Bitmap.Config.ARGB_8888);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:start, stop
             
            @Override 
            public boolean onTouch(View v, MotionEvent event) {
                ImageView iv = (ImageView) v;
                AnimationDrawable ad = (AnimationDrawable) iv.getDrawable();
                ad.stop();
                ad.start();
                return true; 
            } 
        }); 
    } 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:start
            mAnim.stop();
        } 
        if (drawable instanceof AnimationDrawable) {
            mAnim = (AnimationDrawable)drawable;
            if (isShown()) {
                mAnim.start();
            } 
        } else { 
            mAnim = null;
        } 
    } 
 
    @Override 
    public void setImageDrawable(Drawable drawable) {
        super.setImageDrawable(drawable);
        updateAnim(); 
    } 
 
    @Override 
    @android.view.RemotableViewMethod 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isRunning, stop
            animation.run();
        } 
    } 
 
    protected void stopAnimation(final AnimationDrawable animation) {
        if (animation != null && animation.isRunning()) animation.stop();
    } 
} 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDuration, getNumberOfFrames, start
	} 
 
	@Override 
	public void onWindowFocusChanged(boolean hasFocus) {
	  if (hasFocus && mAnimation != null) {
		  mAnimation.start();
		  mKillActivityHandler.sleep(mAnimation.getDuration(0) * mAnimation.getNumberOfFrames());
	  } 
	} 
	 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isRunning, run
        mImageView.setOnClickListener(this);
        mAnimation = (AnimationDrawable) mImageView.getBackground();
    } 
 
    protected void startAnimation(final AnimationDrawable animation) {
        if (animation != null && !animation.isRunning()) {
            animation.run();
        } 
    } 
 
    protected void stopAnimation(final AnimationDrawable animation) {
        if (animation != null && animation.isRunning()) animation.stop();
    } 
} 
 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isRunning, setOneShot, start, stop
			} else { 
				cards[num].setImageResource(getResources().getIdentifier("animqueen", "drawable", getPackageName()));
			} 
		} 
		AnimationDrawable anim = (AnimationDrawable)cards[num].getDrawable();
		anim.setOneShot(true); // 1���ŏI����
		if(anim.isRunning()) anim.stop(); // �A�j���[�V�������Ȃ��~�߂�
		anim.start();
	} 
	 
	public void game(int i) {
		if (card_sound_which[i-1] == 0) {
			playSound(card_sound[i-1]+1);
		} 
		if (card_sound[i-1] == card_sound[clicked]) {//�O�ɃN���b�N���ꂽ���̂Ɠ����ԍ��̃J�[�h��������
			if (TURN == -1) {//king's turn
				cards[i-1].setOnClickListener(null);
				touchAnimation(i-1, "king");
				cards[clicked].setOnClickListener(null);
				touchAnimation(clicked, "king");
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:isRunning
 
	private void bindDotPosition(final ViewHolder holder, final int position) {
		final AnimationDrawable animationDrawable = (AnimationDrawable) holder.dotLocation.getDrawable(); 
		if (mNearestPosition == position) { 
			holder.dotLocation.setVisibility(View.VISIBLE); 
			if (!animationDrawable.isRunning()) { 
				holder.dotLocation.post(new Runnable() { 
					@Override 
					public void run() { 
						animationDrawable.start(); 
					} 
				}); 
			} 
		} else { 
			holder.dotLocation.setVisibility(View.GONE); 
			if (animationDrawable.isRunning()) { 
				holder.dotLocation.post(new Runnable() { 
					@Override 
					public void run() { 
						animationDrawable.stop(); 

5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android AnimationDrawable Questions & Answers:

See Code Examples for Android AnimationDrawable Methods: