下面列出了android.view.animation.Animation#start() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Once the image is downloaded, associates it to the imageView
*/
@Override
protected void onPostExecute(Bitmap bitmap) {
if (isCancelled()) {
bitmap = null;
}
addBitmapToCache(position, bitmap);
if (imageViewReference != null) {
ImageView imageView = imageViewReference.get();
BitmapFetcherTask bitmapDownloaderTask = getBitmapDownloaderTask(imageView);
if (this == bitmapDownloaderTask) {
imageView.setImageBitmap(bitmap);
Animation anim = AnimationUtils.loadAnimation(imageView.getContext(), android.R.anim.fade_in);
imageView.setAnimation(anim);
anim.start();
}
} else {
setInvisible();
}
}
@Override
public void onFocusChange(View v, boolean hasFocus) {
int focus = 0;
if (hasFocus) {
focus = R.anim.enlarge;
} else {
focus = R.anim.decrease;
}
//如果有焦点就放大,没有焦点就缩小
Animation mAnimation = AnimationUtils.loadAnimation(
getActivity().getApplication(), focus);
mAnimation.setBackgroundColor(Color.TRANSPARENT);
mAnimation.setFillAfter(hasFocus);
v.startAnimation(mAnimation);
mAnimation.start();
v.bringToFront();
}
@Override
public void onFocusChange(View v, boolean hasFocus) {
int focus = 0;
if (hasFocus) {
focus = R.anim.enlarge;
} else {
focus = R.anim.decrease;
}
// 如果有焦点就放大,没有焦点就缩小
Animation mAnimation = AnimationUtils.loadAnimation(
mContext, focus);
mAnimation.setBackgroundColor(Color.TRANSPARENT);
mAnimation.setFillAfter(hasFocus);
v.startAnimation(mAnimation);
mAnimation.start();
v.bringToFront();
}
public void removeViewFromCurrentWindow(View child) {
// Message msg = mWindLoop.obtainMessage();
// msg.what = F_WHANDLER_REMOVE_VIEW;
// msg.obj = child;
// mWindLoop.sendMessage(msg);
// Animation removeAnim = child.getAnimation();
// if (null != removeAnim) {
// removeAnim.start();
// }
// removeView(child);
// View children = (View) msg.obj;
Animation removeAnim = child.getAnimation();
if (null != removeAnim) {
removeAnim.start();
}
removeViewList(child);
// msg.obj = null;
}
public void show() {
try {
super.show();
if (this.mDialogDisplayCallback != null) {
this.mDialogDisplayCallback.onShow();
}
StatisticsUtil.statistics(12);
Animation anima = AnimationUtils.loadAnimation(RedPacketSdkManager.getInstance().getApplicationContext(), R.anim.forecast_view_show);
this.mforecastView.setAnimation(anima);
anima.start();
} catch (Exception e) {
}
}
private void animator(final ImageButton imageButton){
Animation animation = AnimationUtils.loadAnimation(getContext(),R.anim.color_item);
animation.setInterpolator(new AccelerateInterpolator());
imageButton.setAnimation(animation);
imageButton.setVisibility(View.VISIBLE);
animation.start();
}
public void start() {
for (Animation animation : pendingAnimations) {
animation.start();
}
started = true;
if (pendingAnimations.isEmpty()) finish();
}
@BindingAdapter("animation")
public static void bindAnimation(View view, @Nullable Animation animation) {
if (animation == null) {
return;
}
view.setAnimation(animation);
animation.start();
}
public void addViewToCurrentWindow(View child) {
//Message msg = mWindLoop.obtainMessage();
//msg.what = F_WHANDLER_ADD_VIEW;
//msg.obj = child;
//mWindLoop.sendMessage(msg);
viewList.add(child);
child.setTag(EViewEntry.F_PLUGIN_VIEW_TAG);
Animation anim = child.getAnimation();
addView(child);
if (null != anim) {
anim.start();
}
bringChildToFront(child);
}
public void setImage(Context ctx, int resId) {
ImageView image = (ImageView)findViewById(R.id.simplehud_image);
image.setImageResource(resId);
if(resId==R.drawable.simplehud_spinner) {
Animation anim = AnimationUtils.loadAnimation(ctx, R.anim.progressbar);
anim.start();
image.startAnimation(anim);
}
}
public void setLoadingScreen(boolean loading, int... frames) {
currentLoadingTime = 0;
Animation loadingTextAnim;
if (GameActivity.getInstance().findViewById(
R.id.loading_text).getAnimation() != null) {
loadingTextAnim = GameActivity.getInstance().findViewById(R.id.loading_text).
getAnimation();
} else if (GameActivity.getInstance().findViewById(
R.id.loading_day_old).getAnimation() != null) {
loadingTextAnim = GameActivity.getInstance().findViewById(R.id.loading_day_old).
getAnimation();
} else {
loadingTextAnim = null;
}
int animDuration = 0;
if (loadingTextAnim != null) {
animDuration = (int) ((loadingTextAnim.getDuration() + loadingTextAnim.getStartOffset())
* TARGET_FPS) / 1000;
loadingTextAnim.start();
}
if (frames.length == 0) { loadingTime = 6 + animDuration; }
else { loadingTime = frames[0] + animDuration; }
if (loading) {
this.loading = true;
GameActivity.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
GameActivity.getInstance().enableLoadingScreen();
}
});
}
else {
GameActivity.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
GameActivity.getInstance().disableLoadingScreen();
}
});
}
}
private void animate(){
Log.e("animate","true");
Runnable r1 = new Runnable() {
@Override
public void run() {
Log.e("animator 1","r");
animator(one);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
animator(two);
animator(six);
}
};
Runnable r3 = new Runnable() {
@Override
public void run() {
animator(three);
animator(seven);
animator(eleven);
}
};
Runnable r4 = new Runnable() {
@Override
public void run() {
animator(four);
animator(eight);
animator(twelve);
animator(sixteen);
}
};
Runnable r5 = new Runnable() {
@Override
public void run() {
animator(five);
animator(nine);
animator(thirteen);
animator(seventeen);
}
};
Runnable r6 = new Runnable() {
@Override
public void run() {
animator(ten);
animator(fourteen);
animator(eighteen);
}
};
Runnable r7 = new Runnable() {
@Override
public void run() {
animator(fifteen);
animator(nineteen);
}
};
Runnable r8 = new Runnable() {
@Override
public void run() {
animator(twenty);
}
};
Runnable r9 = new Runnable() {
@Override
public void run() {
Animation animation = AnimationUtils.loadAnimation(getContext(),android.R.anim.fade_in);
animation.setInterpolator(new AccelerateInterpolator());
twentyOne.setAnimation(animation);
twentyOne.setVisibility(View.VISIBLE);
animation.start();
}
};
android.os.Handler handler = new android.os.Handler();
int counter = 85;
handler.postDelayed(r1,counter);
handler.postDelayed(r2,counter * 2);
handler.postDelayed(r3,counter * 3);
handler.postDelayed(r4,counter * 4);
handler.postDelayed(r5,counter * 5);
handler.postDelayed(r6,counter * 6);
handler.postDelayed(r7,counter * 7);
handler.postDelayed(r8,counter * 8);
handler.postDelayed(r9,counter * 9);
}