Java Code Examples for android.graphics.drawable.AnimationDrawable#addFrame()
The following examples show how to use
android.graphics.drawable.AnimationDrawable#addFrame() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IcsProgressBar.java From zen4android with MIT License | 6 votes |
/** * Convert a AnimationDrawable for use as a barberpole animation. * Each frame of the animation is wrapped in a ClipDrawable and * given a tiling BitmapShader. */ private Drawable tileifyIndeterminate(Drawable drawable) { if (drawable instanceof AnimationDrawable) { AnimationDrawable background = (AnimationDrawable) drawable; final int N = background.getNumberOfFrames(); AnimationDrawable newBg = new AnimationDrawable(); newBg.setOneShot(background.isOneShot()); for (int i = 0; i < N; i++) { Drawable frame = tileify(background.getFrame(i), true); frame.setLevel(10000); newBg.addFrame(frame, background.getDuration(i)); } newBg.setLevel(10000); drawable = newBg; } return drawable; }
Example 2
Source File: IcsProgressBar.java From CSipSimple with GNU General Public License v3.0 | 6 votes |
/** * Convert a AnimationDrawable for use as a barberpole animation. * Each frame of the animation is wrapped in a ClipDrawable and * given a tiling BitmapShader. */ private Drawable tileifyIndeterminate(Drawable drawable) { if (drawable instanceof AnimationDrawable) { AnimationDrawable background = (AnimationDrawable) drawable; final int N = background.getNumberOfFrames(); AnimationDrawable newBg = new AnimationDrawable(); newBg.setOneShot(background.isOneShot()); for (int i = 0; i < N; i++) { Drawable frame = tileify(background.getFrame(i), true); frame.setLevel(10000); newBg.addFrame(frame, background.getDuration(i)); } newBg.setLevel(10000); drawable = newBg; } return drawable; }
Example 3
Source File: SkinCompatProgressBarHelper.java From AndroidSkinAnimator with MIT License | 6 votes |
/** * Convert a AnimationDrawable for use as a barberpole animation. * Each frame of the animation is wrapped in a ClipDrawable and * given a tiling BitmapShader. */ private Drawable tileifyIndeterminate(Drawable drawable) { if (drawable instanceof AnimationDrawable) { AnimationDrawable background = (AnimationDrawable) drawable; final int N = background.getNumberOfFrames(); AnimationDrawable newBg = new AnimationDrawable(); newBg.setOneShot(background.isOneShot()); for (int i = 0; i < N; i++) { Drawable frame = tileify(background.getFrame(i), true); frame.setLevel(10000); newBg.addFrame(frame, background.getDuration(i)); } newBg.setLevel(10000); drawable = newBg; } return drawable; }
Example 4
Source File: IcsProgressBar.java From Libraries-for-Android-Developers with MIT License | 6 votes |
/** * Convert a AnimationDrawable for use as a barberpole animation. * Each frame of the animation is wrapped in a ClipDrawable and * given a tiling BitmapShader. */ private Drawable tileifyIndeterminate(Drawable drawable) { if (drawable instanceof AnimationDrawable) { AnimationDrawable background = (AnimationDrawable) drawable; final int N = background.getNumberOfFrames(); AnimationDrawable newBg = new AnimationDrawable(); newBg.setOneShot(background.isOneShot()); for (int i = 0; i < N; i++) { Drawable frame = tileify(background.getFrame(i), true); frame.setLevel(10000); newBg.addFrame(frame, background.getDuration(i)); } newBg.setLevel(10000); drawable = newBg; } return drawable; }
Example 5
Source File: SampleActivity.java From DragPointView with Apache License 2.0 | 6 votes |
private void initAnim() { animationDrawable = new AnimationDrawable(); animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode1), 100); animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode2), 100); animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode3), 100); animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode4), 100); animationDrawable.addFrame(getResources().getDrawable(R.mipmap.explode5), 100); animationDrawable.setOneShot(true); animationDrawable.setExitFadeDuration(300); animationDrawable.setEnterFadeDuration(100); ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(null, "scaleX", 1.f, 0.f); ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(null, "scaleY", 1.f, 0.f); animatorSet = new AnimatorSet(); animatorSet.setDuration(300l); animatorSet.playTogether(objectAnimator1, objectAnimator2); objectAnimator = ObjectAnimator.ofFloat(null, "alpha", 1.f, 0.f); objectAnimator.setDuration(2000l); }
Example 6
Source File: SkinCompatProgressBarHelper.java From Android-skin-support with MIT License | 6 votes |
/** * Convert a AnimationDrawable for use as a barberpole animation. * Each frame of the animation is wrapped in a ClipDrawable and * given a tiling BitmapShader. */ private Drawable tileifyIndeterminate(Drawable drawable) { if (drawable instanceof AnimationDrawable) { AnimationDrawable background = (AnimationDrawable) drawable; final int N = background.getNumberOfFrames(); AnimationDrawable newBg = new AnimationDrawable(); newBg.setOneShot(background.isOneShot()); for (int i = 0; i < N; i++) { Drawable frame = tileify(background.getFrame(i), true); frame.setLevel(10000); newBg.addFrame(frame, background.getDuration(i)); } newBg.setLevel(10000); drawable = newBg; } return drawable; }
Example 7
Source File: SkinCompatProgressBarHelper.java From Android-skin-support with MIT License | 6 votes |
/** * Convert a AnimationDrawable for use as a barberpole animation. * Each frame of the animation is wrapped in a ClipDrawable and * given a tiling BitmapShader. */ private Drawable tileifyIndeterminate(Drawable drawable) { if (drawable instanceof AnimationDrawable) { AnimationDrawable background = (AnimationDrawable) drawable; final int N = background.getNumberOfFrames(); AnimationDrawable newBg = new AnimationDrawable(); newBg.setOneShot(background.isOneShot()); for (int i = 0; i < N; i++) { Drawable frame = tileify(background.getFrame(i), true); frame.setLevel(10000); newBg.addFrame(frame, background.getDuration(i)); } newBg.setLevel(10000); drawable = newBg; } return drawable; }
Example 8
Source File: SkinCompatProgressBarHelper.java From Android-skin-support with MIT License | 6 votes |
/** * Convert a AnimationDrawable for use as a barberpole animation. * Each frame of the animation is wrapped in a ClipDrawable and * given a tiling BitmapShader. */ private Drawable tileifyIndeterminate(Drawable drawable) { if (drawable instanceof AnimationDrawable) { AnimationDrawable background = (AnimationDrawable) drawable; final int N = background.getNumberOfFrames(); AnimationDrawable newBg = new AnimationDrawable(); newBg.setOneShot(background.isOneShot()); for (int i = 0; i < N; i++) { Drawable frame = tileify(background.getFrame(i), true); frame.setLevel(10000); newBg.addFrame(frame, background.getDuration(i)); } newBg.setLevel(10000); drawable = newBg; } return drawable; }
Example 9
Source File: ProgressBar.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Convert a AnimationDrawable for use as a barberpole animation. * Each frame of the animation is wrapped in a ClipDrawable and * given a tiling BitmapShader. */ private Drawable tileifyIndeterminate(Drawable drawable) { if (drawable instanceof AnimationDrawable) { AnimationDrawable background = (AnimationDrawable) drawable; final int N = background.getNumberOfFrames(); AnimationDrawable newBg = new AnimationDrawable(); newBg.setOneShot(background.isOneShot()); for (int i = 0; i < N; i++) { Drawable frame = tileify(background.getFrame(i), true); frame.setLevel(10000); newBg.addFrame(frame, background.getDuration(i)); } newBg.setLevel(10000); drawable = newBg; } return drawable; }
Example 10
Source File: BossTransferView.java From BlogDemo with Apache License 2.0 | 6 votes |
private void init() { LayoutInflater.from(getContext()).inflate(R.layout.layout_boss_transfer, this); mImg = (ImageView) findViewById(R.id.img); mTemp = findViewById(R.id.line); // mPb = (ProgressBar) findViewById(R.id.progress); mPb = (ImageView) findViewById(R.id.progress); mHandleView.getLocationInWindow(mLocation); int sbh = Util.getStatusBarHeight(getContext()); mImg.setTranslationY(mLocation[1] - sbh); mTemp.setTranslationY(mLocation[1] + mImg.getMeasuredHeight() / 2 + sbh); mPb.setVisibility(GONE); Bitmap bm = getViewImg(mHandleView); if (bm != null) { mImg.setImageBitmap(getViewImg(mHandleView)); } AnimationDrawable ad = new AnimationDrawable(); ad.addFrame(getDrawable(R.mipmap.icon_refresh_left), 200); ad.addFrame(getDrawable(R.mipmap.icon_refresh_center), 200); ad.addFrame(getDrawable(R.mipmap.icon_refresh_right), 200); mPb.setImageDrawable(ad); ad.setOneShot(false); ad.start(); }
Example 11
Source File: IcsProgressBar.java From zhangshangwuda with Apache License 2.0 | 6 votes |
/** * Convert a AnimationDrawable for use as a barberpole animation. * Each frame of the animation is wrapped in a ClipDrawable and * given a tiling BitmapShader. */ private Drawable tileifyIndeterminate(Drawable drawable) { if (drawable instanceof AnimationDrawable) { AnimationDrawable background = (AnimationDrawable) drawable; final int N = background.getNumberOfFrames(); AnimationDrawable newBg = new AnimationDrawable(); newBg.setOneShot(background.isOneShot()); for (int i = 0; i < N; i++) { Drawable frame = tileify(background.getFrame(i), true); frame.setLevel(10000); newBg.addFrame(frame, background.getDuration(i)); } newBg.setLevel(10000); drawable = newBg; } return drawable; }
Example 12
Source File: AnimationUtils.java From AndroidStudyDemo with GNU General Public License v2.0 | 5 votes |
public static AnimationDrawable initAnimationDrawable(Context context, int[] drawableIds, int durationTime, boolean isOneShot) { AnimationDrawable mAnimationDrawable = new AnimationDrawable(); for (int i = 0; i < drawableIds.length; i++) { int id = drawableIds[i]; mAnimationDrawable.addFrame(context.getResources().getDrawable(id), durationTime); } mAnimationDrawable.setOneShot(isOneShot); return mAnimationDrawable; }
Example 13
Source File: DrawableProvider.java From TextDrawable with MIT License | 5 votes |
public Drawable getRectWithAnimation() { TextDrawable.IBuilder builder = TextDrawable.builder() .rect(); AnimationDrawable animationDrawable = new AnimationDrawable(); for (int i = 10; i > 0; i--) { TextDrawable frame = builder.build(String.valueOf(i), mGenerator.getRandomColor()); animationDrawable.addFrame(frame, 1200); } animationDrawable.setOneShot(false); animationDrawable.start(); return animationDrawable; }
Example 14
Source File: BloomStyleActivity.java From SpringFloatingActionMenu with Apache License 2.0 | 5 votes |
private void createFabReverseFrameAnim() { frameReverseAnim = new AnimationDrawable(); frameReverseAnim.setOneShot(true); Resources resources = getResources(); for (int i = frameAnimRes.length - 1; i >= 0; i--) { frameReverseAnim.addFrame(resources.getDrawable(frameAnimRes[i]), frameDuration); } }
Example 15
Source File: BloomStyleActivity.java From SpringFloatingActionMenu with Apache License 2.0 | 5 votes |
private void createFabFrameAnim() { frameAnim = new AnimationDrawable(); frameAnim.setOneShot(true); Resources resources = getResources(); for (int res : frameAnimRes) { frameAnim.addFrame(resources.getDrawable(res), frameDuration); } }
Example 16
Source File: TumblrStyleActivity.java From SpringFloatingActionMenu with Apache License 2.0 | 5 votes |
private void createFabReverseFrameAnim() { frameReverseAnim = new AnimationDrawable(); frameReverseAnim.setOneShot(true); Resources resources = getResources(); for (int i = frameAnimRes.length - 1; i >= 0; i--) { frameReverseAnim.addFrame(resources.getDrawable(frameAnimRes[i]), frameDuration); } }
Example 17
Source File: TumblrStyleActivity.java From SpringFloatingActionMenu with Apache License 2.0 | 5 votes |
private void createFabFrameAnim() { frameAnim = new AnimationDrawable(); frameAnim.setOneShot(true); Resources resources = getResources(); for (int res : frameAnimRes) { frameAnim.addFrame(resources.getDrawable(res), frameDuration); } }
Example 18
Source File: RCTImageSequenceView.java From react-native-image-sequence with MIT License | 5 votes |
private void setupAnimationDrawable() { AnimationDrawable animationDrawable = new AnimationDrawable(); for (int index = 0; index < bitmaps.size(); index++) { BitmapDrawable drawable = new BitmapDrawable(this.getResources(), bitmaps.get(index)); animationDrawable.addFrame(drawable, 1000 / framesPerSecond); } animationDrawable.setOneShot(!this.loop); this.setImageDrawable(animationDrawable); animationDrawable.start(); }
Example 19
Source File: ItemConversationAdapter.java From DragPointView with Apache License 2.0 | 5 votes |
public ItemConversationAdapter(Context context, List<ConversationEntity> objects) { this.context = context; this.layoutInflater = LayoutInflater.from(context); this.objects = objects; animationDrawable = new AnimationDrawable(); animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode1), 100); animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode2), 100); animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode3), 100); animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode4), 100); animationDrawable.addFrame(context.getResources().getDrawable(R.mipmap.explode5), 100); animationDrawable.setOneShot(true); animationDrawable.setExitFadeDuration(300); animationDrawable.setEnterFadeDuration(100); }
Example 20
Source File: UDImageView.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
/** * 开始帧动画(目前只支持本地动画) * * @param images * @param duration * @return */ public UDImageView startAnimationImages(String[] images, int duration, boolean repeat) { T view = getView(); if (view != null) { Drawable[] frames = null; if (images != null && images.length > 0) { if (getLuaResourceFinder() != null) { frames = new Drawable[images.length]; for (int i = 0; i < images.length; i++) { frames[i] = getLuaResourceFinder().findDrawable(images[i]); } } if (frames != null && frames.length > 0) { mFrameAnimation = new AnimationDrawable(); try { for (Drawable frame : frames) { mFrameAnimation.addFrame(frame, duration); } } catch (Throwable e) { } mFrameAnimation.setOneShot(!repeat); LuaViewUtil.setBackground(view, mFrameAnimation); mFrameAnimation.setVisible(true, true); mFrameAnimation.start(); } } } return this; }