本文整理汇总了Java中android.graphics.drawable.AnimationDrawable类的典型用法代码示例。如果您正苦于以下问题:Java AnimationDrawable类的具体用法?Java AnimationDrawable怎么用?Java AnimationDrawable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnimationDrawable类属于android.graphics.drawable包,在下文中一共展示了AnimationDrawable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRefreshHeaderView
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
@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;
}
示例2: initViews
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
private void initViews() {
mPlayingMatrix = (ImageView) findViewById(R.id.iv_now_playing_matrix);
AnimationDrawable animationDrawable = (AnimationDrawable) mPlayingMatrix.getBackground();
animationDrawable.start();
mSongName = (TextView) findViewById(R.id.tv_now_playing_song_name);
mArtist = (TextView) findViewById(R.id.tv_now_playing_singer);
mCurrentPosition = (TextView) findViewById(R.id.tv_now_playing_time);
mAudioSkb = (SeekBar) findViewById(R.id.sb_audio);
mPlayModeBtn = (Button) findViewById(R.id.btn_audio_playmode);
mPreBtn = (Button) findViewById(R.id.btn_audio_previous);
mPlayPauseBtn = (Button) findViewById(R.id.btn_audio_playing_pause);
mNextBtn = (Button) findViewById(R.id.btn_audio_next);
mLyricBtn = (Button) findViewById(R.id.btn_audio_lyrc);
mPlayModeBtn.setOnClickListener(mClickListener);
mPreBtn.setOnClickListener(mClickListener);
mPlayPauseBtn.setOnClickListener(mClickListener);
mNextBtn.setOnClickListener(mClickListener);
mLyricBtn.setOnClickListener(mClickListener);
mLyricShowView = (LyricShowView) findViewById(R.id.lyric_view);
mAudioSkb.setOnSeekBarChangeListener(new AudioSeekChangeListener());
}
示例3: onCreate
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle(title);
infoText = (TextView) findViewById(R.id.infoView);
imgView = (ImageView) findViewById(R.id.cardbg);
imgView.setBackgroundResource(R.drawable.myanim);
_animation = (AnimationDrawable) imgView.getBackground();
_animation.setOneShot(false);
uiHandler = new MyHandler(this);
mBluetoothReader = new BluetoothReader();
mBluetoothReader.setOnReaderStateListener(new BluetoothReader.OnReaderStateListener() {
@Override
public void onReaderStateChange(String readerName, int readerState) {
if (readerName.isEmpty() == false) {
uiHandler.obtainMessage(READER_MESSAGE, readerState, -1, readerName).sendToTarget();
}
}
});
View scan = findViewById(R.id.btScan);
scan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
infoText.setText("Select bluetooth reader for connect...");
Intent serverIntent = new Intent(TestActivity3.this, DeviceListActivity.class);
startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
}
});
}
示例4: onActivityCreated
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mLlProgressBar = getView(R.id.ll_progress_bar);
ImageView img = getView(R.id.img_progress);
// 加载动画
mAnimationDrawable = (AnimationDrawable) img.getDrawable();
// 默认进入页面就开启动画
if (!mAnimationDrawable.isRunning()) {
mAnimationDrawable.start();
}
mRefresh = getView(R.id.ll_error_refresh);
// 点击加载失败布局
mRefresh.setOnClickListener(new PerfectClickListener() {
@Override
protected void onNoDoubleClick(View v) {
showLoading();
onRefresh();
}
});
bindingView.getRoot().setVisibility(View.GONE);
}
示例5: initView
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
private void initView() {
LayoutInflater.from(mContext).inflate(R.layout.kaws_refresh_header, this);
ImageView img = (ImageView) findViewById(R.id.img);
animationDrawable = (AnimationDrawable) img.getDrawable();
if (animationDrawable.isRunning()) {
animationDrawable.stop();
}
msg = (TextView) findViewById(R.id.msg);
measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
mMeasuredHeight = getMeasuredHeight();
setGravity(Gravity.CENTER_HORIZONTAL);
mContainer = (LinearLayout) findViewById(R.id.container);
mContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 0));
this.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
示例6: getLoadMoreFooterView
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
/**
* 获取上拉加载更多控件,如果不喜欢这种上拉刷新风格可重写该方法实现自定义LoadMoreFooterView
*
* @return
*/
public View getLoadMoreFooterView() {
if (!mIsLoadingMoreEnabled) {
return null;
}
if (mLoadMoreFooterView == null) {
mLoadMoreFooterView = View.inflate(mContext, R.layout.view_normal_refresh_footer, null);
mLoadMoreFooterView.setBackgroundColor(Color.TRANSPARENT);
if (mLoadMoreBackgroundColorRes != -1) {
mLoadMoreFooterView.setBackgroundResource(mLoadMoreBackgroundColorRes);
}
if (mLoadMoreBackgroundDrawableRes != -1) {
mLoadMoreFooterView.setBackgroundResource(mLoadMoreBackgroundDrawableRes);
}
mFooterStatusTv = (TextView) mLoadMoreFooterView.findViewById(R.id.tv_normal_refresh_footer_status);
mFooterChrysanthemumIv = (ImageView) mLoadMoreFooterView.findViewById(R.id.iv_normal_refresh_footer_chrysanthemum);
mFooterChrysanthemumAd = (AnimationDrawable) mFooterChrysanthemumIv.getDrawable();
mFooterStatusTv.setText(mLodingMoreText);
}
return mLoadMoreFooterView;
}
示例7: error
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
@Override public void error(Exception e) {
ImageView target = this.target.get();
if (target == null) {
return;
}
Drawable placeholder = target.getDrawable();
if (placeholder instanceof AnimationDrawable) {
((AnimationDrawable) placeholder).stop();
}
if (errorResId != 0) {
target.setImageResource(errorResId);
} else if (errorDrawable != null) {
target.setImageDrawable(errorDrawable);
}
if (callback != null) {
callback.onError(e);
}
}
示例8: reset
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
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);
}
}
示例9: showLoadingOrNoNet
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
/**
* 返回是否应该加载数据
*
* @param empty 页面是否为空
* @param showLoading 如果为空,且有网络的情况下是否显示正在加载,若为false则显示点击重新加载
* @param 用来显示这些图片的ImageView
**/
public static boolean showLoadingOrNoNet(boolean empty, boolean showLoading, boolean feedbackIfNoNet, ImageView imgState) {
if (empty) {
if (feedbackIfNoNet ? checkNetStateAndFeedbackUser() : Network.isNetConnected(get())) {
if (showLoading) {
imgState.setVisibility(View.VISIBLE);
imgState.setImageResource(R.drawable.anim_list_i_pull_2_refresh_header);
AnimationDrawable anim = (AnimationDrawable)imgState.getDrawable();
anim.start();
return true;
} else {
imgState.setVisibility(View.VISIBLE);
imgState.setImageResource(R.drawable.img_common_click_reload);
}
} else {
imgState.setVisibility(View.VISIBLE);
imgState.setImageResource(R.drawable.img_common_no_net);
}
} else {
imgState.setImageResource(0);
imgState.setVisibility(View.GONE);
}
return false;
}
示例10: onCreate
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button =(Button)findViewById(R.id.button);
view = (ImageView)findViewById(R.id.imageView);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
view.setBackgroundResource(R.drawable.face_emotion);
AnimationDrawable frameAnimation2 = (AnimationDrawable) view.getBackground();
frameAnimation2.stop();
frameAnimation2.start();
}
});
}
示例11: recreateWithParams
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
public void recreateWithParams(Context context, @ColorInt int spinnerColor, int duration, boolean clockwise) {
boolean wasRunning = false;
boolean oneShot = isOneShot();
if (((AnimationDrawable)this.getBackground()).isRunning()) {
wasRunning = true;
stop();
}
AnimationDrawable newSpinner = createSpinner(context, spinnerColor, duration, clockwise);
if (newSpinner != null) {
if (oneShot) newSpinner.setOneShot(true);
this.spinnerColor = spinnerColor;
this.duration = duration;
this.clockwise = clockwise;
updateSpinner(newSpinner);
}
if (wasRunning) start();
}
示例12: stopPlayVoice
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
/**
* 结束播放音频
*/
public static void stopPlayVoice() {
if (player != null && player.isPlaying()) {
player.release();
player = null;
}
if (v_playVoice != null) {
try {
((AnimationDrawable) v_playVoice.getBackground()).stop();
((AnimationDrawable) v_playVoice.getBackground())
.selectDrawable(0);
v_playVoice = null;
} catch (Exception e) {
e.printStackTrace();
}
// 注意
// :此处try\catch用来修复BUG——播放语音时,滑动观看交流信息再点击语音会卡死。若是播放时,来回滑动过多,也有几率造成卡死。
}
}
示例13: onWindowFocusChanged
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
@Override
public void onWindowFocusChanged(boolean hasFocus) {
ImageView imageViewAnimTop = (ImageView) findViewById(R.id.imageView_animation_top);
ImageView imageViewAnimBottom = (ImageView) findViewById(R.id.imageView_animation_bottom);
AnimationDrawable animTop = (AnimationDrawable) imageViewAnimTop.getBackground();
AnimationDrawable animBottom = (AnimationDrawable) imageViewAnimBottom.getBackground();
animTop.start();
animBottom.start();
super.onWindowFocusChanged(hasFocus);
}
示例14: isRunning
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
public boolean isRunning() {
if (object == null)
return false;
if (object instanceof AnimationDrawable) {
return ((AnimationDrawable) object).isRunning();
} else if (object instanceof Animator) {
return ((Animator) object).isRunning();
} else if (object instanceof Animation) {
if (((Animation) object).hasStarted()) {
return !((Animation) object).hasEnded();
} else {
return false;
}
}
return false;
}
示例15: doOnViewCreated
import android.graphics.drawable.AnimationDrawable; //导入依赖的package包/类
@Override
public void doOnViewCreated(View v, @Nullable Bundle savedInstanceState) {
speakerLevel = (ImageView) v
.findViewById(R.id.speaker_shield_imageview);
femaleBtn = (Button) v.findViewById(R.id.increaseBtn);
maleBtn = (Button) v.findViewById(R.id.decreaseBtn);
ttsText = (OneSheeldTextView) v.findViewById(R.id.ttsText);
ttsText.setMovementMethod(new ScrollingMovementMethod());
animation = (AnimationDrawable) speakerLevel.getBackground();
}