类android.graphics.drawable.AnimationDrawable源码实例Demo

下面列出了怎么用android.graphics.drawable.AnimationDrawable的API类实例代码及写法,或者点击链接到github查看源代码。

public final void refreshing() {
	if (null != mHeaderText) {
		mHeaderText.setText(mRefreshingLabel);
	}

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).start();
	} else {
		// Now call the callback
		refreshingImpl();
	}

	if (null != mSubHeaderText) {
		mSubHeaderText.setVisibility(View.GONE);
	}
}
 
源代码2 项目: WidgetCase   文件: RefreshView.java
private void init(Context context) {
        mContext = context;

        DisplayMetrics dm = getResources().getDisplayMetrics();
        mScreenW = dm.widthPixels;
        mHeadBmp = BitmapFactory.decodeResource(getResources(), R.drawable.load_more_1);

//		mScrDistance = mScreenH / 3 - 46;
        mHeadW = mHeadBmp.getWidth();
        mHeadH = mHeadBmp.getHeight();
        mInitLeftPX = mScreenW / 2 - mHeadW;
        mInitRightPX = mScreenW / 2 + mHeadW;
        mBmpL = mScreenW / 2 - mHeadBmp.getWidth() / 2;
        mBmpT = 0;

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
        mPaint.setColor(Color.RED);
        mPaint.setStyle(Style.FILL);//设置非填充
        mScroller = new Scroller(mContext, new DecelerateInterpolator());
        mScroller1 = new Scroller(mContext, new DecelerateInterpolator());

        mAniDraw = (AnimationDrawable) mAnimList.getDrawable();
    }
 
源代码3 项目: aurora-imui   文件: ViewHolderController.java
public void notifyAnimStop() {
    ImageView imageView = mData.get(mLastPlayPosition);
    try {
        if (imageView != null) {
            AnimationDrawable anim = (AnimationDrawable) imageView.getDrawable();
            anim.stop();
            if (mIsSender) {
                imageView.setImageResource(mSendDrawable);
            } else {
                imageView.setImageResource(mReceiveDrawable);
            }

        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}
 
源代码4 项目: android_9.0.0_r45   文件: ProgressBar.java
/**
 * 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;
}
 
源代码5 项目: tv-samples   文件: OnboardingFragment.java
@Override
protected void onPageChanged(final int newPage, int previousPage) {
    if (mContentAnimator != null) {
        mContentAnimator.end();
    }
    ArrayList<Animator> animators = new ArrayList<>();
    Animator fadeOut = createFadeOutAnimator(mContentView);

    fadeOut.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mContentView.setImageDrawable(getResources().getDrawable(pageImages[newPage]));
            ((AnimationDrawable) mContentView.getDrawable()).start();
        }
    });
    animators.add(fadeOut);
    animators.add(createFadeInAnimator(mContentView));
    AnimatorSet set = new AnimatorSet();
    set.playSequentially(animators);
    set.start();
    mContentAnimator = set;
}
 
源代码6 项目: iSCAU-Android   文件: LoadingLayout.java
public final void reset() {
	if (null != mHeaderText) {
		mHeaderText.setText(mPullLabel);
	}
	mHeaderImage.setVisibility(View.VISIBLE);

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).stop();
	} else {
		// Now call the callback
		resetImpl();
	}

	if (null != mSubHeaderText) {
		if (TextUtils.isEmpty(mSubHeaderText.getText())) {
			mSubHeaderText.setVisibility(View.GONE);
		} else {
			mSubHeaderText.setVisibility(View.VISIBLE);
		}
	}
}
 
@Override
public View getRefreshHeaderView() {
    if (mRefreshHeaderView == null) {
        mRefreshHeaderView = View.inflate(mContext, R.layout.view_refresh_header_normal, null);
        mRefreshHeaderView.setBackgroundColor(Color.TRANSPARENT);
        if (mRefreshViewBackgroundColorRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundColorRes);
        }
        if (mRefreshViewBackgroundDrawableRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundDrawableRes);
        }
        mHeaderStatusTv = (TextView) mRefreshHeaderView.findViewById(R.id.tv_normal_refresh_header_status);
        mHeaderArrowIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_arrow);
        mHeaderChrysanthemumIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_chrysanthemum);
        mHeaderChrysanthemumAd = (AnimationDrawable) mHeaderChrysanthemumIv.getDrawable();
        mHeaderStatusTv.setText(mPullDownRefreshText);
    }
    return mRefreshHeaderView;
}
 
源代码8 项目: MyHearts   文件: MainActivityDrawerLayout.java
/**
 * 自己去调整
 */
private void initAnimation() {
    // 获取ImageView上的动画背景
    AnimationDrawable spinnerLive = (AnimationDrawable) mIvLive.getBackground();

    // 开始动画
    spinnerLive.start();

    mIvImg = (ImageView) findViewById(R.id.img_img);

    // 获取ImageView上的动画背景
    AnimationDrawable spinnerImg = (AnimationDrawable) mIvImg.getBackground();
    // 开始动画
    spinnerImg.start();

}
 
/**
 * 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;
}
 
源代码10 项目: allenglish   文件: WordDetailsAdapter.java
@Override
public void onBindViewHolder(ExampleSentenceContentAdapter.ViewHolder holder, int position) {
    final int pos = position;
    StringBuilder sb = new StringBuilder();
    sb.append(mDetailedWord.sentence.get(pos).Network_en).append("\n").append(mDetailedWord.sentence.get(pos).Network_cn);
    if (pos != getItemCount() - 1) {
        sb.append("\n");
    }
    holder.sentenceContent.setText(sb);
    ImageView horn = holder.horn;
    horn.setBackgroundResource(R.drawable.animation_horn_color);
    mSentenceHornAnimations.add((AnimationDrawable) horn.getBackground());
    horn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mSentenceHornAnimations.get(pos + 2).isRunning()) {
                return;
            }
            stopAnimation();
            mSentenceHornAnimations.get(pos + 2).start();
            mPlayAudio.play(BaseApplication.getInstance(), mDetailedWord.sentence.get(pos).tts_mp3, 3);
        }
    });
}
 
源代码11 项目: BloodBank   文件: SplashActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    imageView = findViewById(R.id.load_image);

    AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getDrawable();
    animationDrawable.start();

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
            startActivity(intent);
            finish();
        }
    }, 2000);
}
 
源代码12 项目: Eyebrows   文件: Eyebrows.java
/**
 * start the gradient anim
 */
public void startGradientAnimation(){
    if(mView!=null){
        mView.setBackgroundResource(mGradientAnimation);
        mAnimationDrawable = (AnimationDrawable) mView.getBackground();
        if(mAnimationDrawable!=null){
            mView.setBackground(mAnimationDrawable);
            mAnimationDrawable.setEnterFadeDuration(mDuration);
            mAnimationDrawable.setExitFadeDuration(mDuration);
            mView.post(new Runnable() {
                @Override
                public void run() {
                    mAnimationDrawable.start();
                }
            });
        }
    }
}
 
源代码13 项目: fitness_Android   文件: LoadingDialog.java
private void initViews() {
	this.txt=(TextView)findViewById(R.id.loading_content_text);
	this.progressBar=(RoundProgressBar)findViewById(R.id.roundProgressBar);
	this.normal_loading_bar=(ImageView)findViewById(R.id.normal_loading);
	this.txt.setText(msg);
	
	this.normal_loading_bar.setBackgroundResource(R.drawable.loading_animation);
	// 通过ImageView对象拿到背景显示的AnimationDrawable
	mAnimation = (AnimationDrawable) normal_loading_bar.getBackground();
	// 为了防止在onCreate方法中只显示第一帧的解决方案之一
	this.normal_loading_bar.post(new Runnable() {
		@Override
		public void run() {
			mAnimation.start();
		}
	});
	
	this.normal_loading_bar.setVisibility(View.VISIBLE);
	this.progressBar.setVisibility(View.GONE);
}
 
源代码14 项目: SweetMusicPlayer   文件: LoadingLayout.java
public final void refreshing() {
	if (null != mHeaderText) {
		mHeaderText.setText(mRefreshingLabel);
	}

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).start();
	} else {
		// Now call the callback
		refreshingImpl();
	}

	if (null != mSubHeaderText) {
		mSubHeaderText.setVisibility(View.GONE);
	}
}
 
源代码15 项目: Social   文件: LoadingLayout.java
public final void reset() {
	if (null != mHeaderText) {
		mHeaderText.setText(mPullLabel);
	}
	mHeaderImage.setVisibility(View.VISIBLE);

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).stop();
	} else {
		// Now call the callback
		resetImpl();
	}

	if (null != mSubHeaderText) {
		if (TextUtils.isEmpty(mSubHeaderText.getText())) {
			mSubHeaderText.setVisibility(View.GONE);
		} else {
			mSubHeaderText.setVisibility(View.VISIBLE);
		}
	}
}
 
源代码16 项目: BlogDemo   文件: BossTransferView.java
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();
    }
 
源代码17 项目: zhangshangwuda   文件: IcsProgressBar.java
/**
 * 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;
}
 
private void setTypingAnimation(boolean start) {
    if (actionBarLayer == null) {
        return;
    }
    if (start) {
        try {
            actionBarLayer.setSubTitleIcon(R.drawable.typing_dots, OSUtilities.dp(4));
            AnimationDrawable mAnim = (AnimationDrawable) actionBarLayer.getSubTitleIcon();
            mAnim.setAlpha(200);
            mAnim.start();
        } catch (Exception e) {
            FileLog.e("tmessages", e);
        }
    } else {
        actionBarLayer.setSubTitleIcon(0, 0);
    }
}
 
源代码19 项目: DMAudioStreamer   文件: AdapterMusic.java
private Drawable getDrawableByState(Context context, int state) {
    switch (state) {
        case PlaybackStateCompat.STATE_NONE:
            Drawable pauseDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(pauseDrawable, colorPlay);
            return pauseDrawable;
        case PlaybackStateCompat.STATE_PLAYING:
            AnimationDrawable animation = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(animation, colorPlay);
            animation.start();
            return animation;
        case PlaybackStateCompat.STATE_PAUSED:
            Drawable playDrawable = ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(playDrawable, colorPause);
            return playDrawable;
        default:
            Drawable noneDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(noneDrawable, colorPlay);
            return noneDrawable;
    }
}
 
源代码20 项目: AndroidDemo   文件: FloatBallActivity.java
public void onClick(View v) {
    int id = v.getId();
    if (R.id.open == id) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) {
            Toast.makeText(this, "请在设置中开启弹窗权限", Toast.LENGTH_LONG).show();
            return;
        }
        if (!Tools.isServiceRunning(this, FloatBallService.class.getName())) {
            startService(new Intent(this, FloatBallService.class));
        }
    } else if (R.id.close == id) {
        if (Tools.isServiceRunning(this, FloatBallService.class.getName())) {
            stopService(new Intent(this, FloatBallService.class));
        }
    } else if (R.id.startAnim == id) {

        wifi.setBackgroundResource(R.drawable.wifi_anim);
        AnimationDrawable animation = (AnimationDrawable) wifi.getBackground();
        animation.start();

    } else if (R.id.stopAnim == id) {
        stopAnimation();
    }
}
 
源代码21 项目: Roid-Library   文件: LoadingLayout.java
public final void refreshing() {
    if (null != mHeaderText) {
        mHeaderText.setText(mRefreshingLabel);
    }

    if (mUseIntrinsicAnimation) {
        ((AnimationDrawable) mHeaderImage.getDrawable()).start();
    } else {
        // Now call the callback
        refreshingImpl();
    }

    if (null != mSubHeaderText) {
        mSubHeaderText.setVisibility(View.GONE);
    }
}
 
源代码22 项目: letv   文件: LoadingLayout.java
public final void reset() {
    if (this.mHeaderText != null) {
        this.mHeaderText.setText(this.mPullLabel);
    }
    this.mHeaderImage.setVisibility(0);
    if (this.mUseIntrinsicAnimation) {
        ((AnimationDrawable) this.mHeaderImage.getDrawable()).stop();
    } else {
        resetImpl();
    }
    if (this.mSubHeaderText == null) {
        return;
    }
    if (TextUtils.isEmpty(this.mSubHeaderText.getText())) {
        this.mSubHeaderText.setVisibility(8);
    } else {
        this.mSubHeaderText.setVisibility(0);
    }
}
 
public final void reset() {
	if (null != mHeaderText) {
		mHeaderText.setText(mPullLabel);
	}
	mHeaderImage.setVisibility(View.VISIBLE);

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).stop();
	} else {
		// Now call the callback
		resetImpl();
	}

	if (null != mSubHeaderText) {
		if (TextUtils.isEmpty(mSubHeaderText.getText())) {
			mSubHeaderText.setVisibility(View.GONE);
		} else {
			mSubHeaderText.setVisibility(View.VISIBLE);
		}
	}
}
 
源代码24 项目: sctalk   文件: LoadingLayout.java
public final void refreshing() {
    if (null != mHeaderText) {
        mHeaderText.setText(mRefreshingLabel);
        // mSubHeaderText.setText(mLastRefresh+sdf.format(date));
    }

    if (mUseIntrinsicAnimation) {
        ((AnimationDrawable) mHeaderImage.getDrawable()).start();
    } else {
        // Now call the callback
        refreshingImpl();
    }

    // if (null != mSubHeaderText) {
    // mSubHeaderText.setVisibility(View.GONE);
    // }
}
 
源代码25 项目: AndroidBase   文件: LoadingLayout.java
public final void refreshing() {
	if (null != mHeaderText) {
		mHeaderText.setText(mRefreshingLabel);
	}

	if (mUseIntrinsicAnimation) {
		((AnimationDrawable) mHeaderImage.getDrawable()).start();
	} else {
		// Now call the callback
		refreshingImpl();
	}

	if (null != mSubHeaderText) {
		mSubHeaderText.setVisibility(View.GONE);
	}
}
 
源代码26 项目: candybar   文件: ImageViewAware.java
@Override
protected void setImageDrawableInto(Drawable drawable, View view) {
    ((ImageView) view).setImageDrawable(drawable);
    if (drawable instanceof AnimationDrawable) {
        ((AnimationDrawable) drawable).start();
    }
}
 
源代码27 项目: miappstore   文件: MoreHolder.java
@Override
public View initView() {
    View view = View.inflate(context, R.layout.item_load_more, null);
    load_empty = view.findViewById(R.id.load_empty);
    load_error = view.findViewById(R.id.load_error);
    load_more = view.findViewById(R.id.load_more);
    iv_loadmore = (ImageView) view.findViewById(R.id.iv_loadmore);
    background = (AnimationDrawable) iv_loadmore.getBackground();
    background.start();
    return view;
}
 
源代码28 项目: ReadMark   文件: MTRefreshCreator.java
public MTRefreshCreator(Context context, ViewGroup parent) {
    mHeader = LayoutInflater.from(context)
            .inflate(R.layout.just_a_mt_refresh_header, parent, false);
    mFirstStepView = (MTFirstView) mHeader.findViewById(R.id.first_view);
    mSecondStepView = (MTSecondView) mHeader.findViewById(R.id.second_view);
    mThirdStepView = (MTThirdView) mHeader.findViewById(R.id.third_view);
    mHeaderText = (TextView) mHeader.findViewById(R.id.tv_pull_to_refresh);
    mSecondStepView.setBackgroundResource(R.drawable.mt_pull_to_refresh_second_anim_in);
    mThirdStepView.setBackgroundResource(R.drawable.mt_pull_to_refresh_third_anim);
    //获取补间动画
    mSecondAnimIn = (AnimationDrawable) mSecondStepView.getBackground();
    mThirdAnim = (AnimationDrawable) mThirdStepView.getBackground();
}
 
源代码29 项目: ahoy-onboarding   文件: FlowingGradient.java
private void init() {
    setBackgroundResource(draw);
    final AnimationDrawable frameAnimation = (AnimationDrawable) getBackground();
    frameAnimation.setEnterFadeDuration(duration);
    frameAnimation.setExitFadeDuration(duration);
    post(new Runnable(){
        public void run(){
            frameAnimation.start();
        }
    });
}
 
源代码30 项目: android-project-wo2b   文件: LoadingLayout.java
public final void setLoadingDrawable(Drawable imageDrawable) {
	// Set Drawable
	mHeaderImage.setImageDrawable(imageDrawable);
	mUseIntrinsicAnimation = (imageDrawable instanceof AnimationDrawable);

	// Now call the callback
	onLoadingDrawableSet(imageDrawable);
}
 
 同包方法