下面列出了怎么用android.animation.AnimatorInflater的API类实例代码及写法,或者点击链接到github查看源代码。
public DashboardFlipViewHolder(View view) {
super(view);
context = view.getContext();
previousFlipDirection = NOT_SET;
setRightOut = (AnimatorSet) AnimatorInflater.loadAnimator(context,
R.animator.card_flip_right_out);
setLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(context,
R.animator.card_flip_left_in);
setRightIn = (AnimatorSet) AnimatorInflater.loadAnimator(context,
R.animator.card_flip_right_in);
setLeftOut = (AnimatorSet) AnimatorInflater.loadAnimator(context,
R.animator.card_flip_left_out);
front = (FrameLayout) view.findViewById(R.id.card_front);
back = (FrameLayout) view.findViewById(R.id.card_back);
}
public Animator createShowUpAnimator(final View target) {
if (mHasCustomAnimationParams) {
final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_X, mShowUpStartXScale,
KEY_PREVIEW_SHOW_UP_END_SCALE);
final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_Y, mShowUpStartYScale,
KEY_PREVIEW_SHOW_UP_END_SCALE);
final AnimatorSet showUpAnimator = new AnimatorSet();
showUpAnimator.play(scaleXAnimator).with(scaleYAnimator);
showUpAnimator.setDuration(mShowUpDuration);
showUpAnimator.setInterpolator(DECELERATE_INTERPOLATOR);
return showUpAnimator;
}
final Animator animator = AnimatorInflater.loadAnimator(
target.getContext(), mShowUpAnimatorResId);
animator.setTarget(target);
animator.setInterpolator(DECELERATE_INTERPOLATOR);
return animator;
}
public Animator createDismissAnimator(final View target) {
if (mHasCustomAnimationParams) {
final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_X, mDismissEndXScale);
final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_Y, mDismissEndYScale);
final AnimatorSet dismissAnimator = new AnimatorSet();
dismissAnimator.play(scaleXAnimator).with(scaleYAnimator);
final int dismissDuration = Math.min(mDismissDuration, mLingerTimeout);
dismissAnimator.setDuration(dismissDuration);
dismissAnimator.setInterpolator(ACCELERATE_INTERPOLATOR);
return dismissAnimator;
}
final Animator animator = AnimatorInflater.loadAnimator(
target.getContext(), mDismissAnimatorResId);
animator.setTarget(target);
animator.setInterpolator(ACCELERATE_INTERPOLATOR);
return animator;
}
public Animator createShowUpAnimator(final View target) {
if (mHasCustomAnimationParams) {
final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_X, mShowUpStartXScale,
KEY_PREVIEW_SHOW_UP_END_SCALE);
final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_Y, mShowUpStartYScale,
KEY_PREVIEW_SHOW_UP_END_SCALE);
final AnimatorSet showUpAnimator = new AnimatorSet();
showUpAnimator.play(scaleXAnimator).with(scaleYAnimator);
showUpAnimator.setDuration(mShowUpDuration);
showUpAnimator.setInterpolator(DECELERATE_INTERPOLATOR);
return showUpAnimator;
}
final Animator animator = AnimatorInflater.loadAnimator(
target.getContext(), mShowUpAnimatorResId);
animator.setTarget(target);
animator.setInterpolator(DECELERATE_INTERPOLATOR);
return animator;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_live_barcode);
preview = findViewById(R.id.camera_preview);
graphicOverlay = findViewById(R.id.camera_preview_graphic_overlay);
graphicOverlay.setOnClickListener(this);
cameraSource = new CameraSource(graphicOverlay);
promptChip = findViewById(R.id.bottom_prompt_chip);
promptChipAnimator =
(AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.bottom_prompt_chip_enter);
promptChipAnimator.setTarget(promptChip);
findViewById(R.id.close_button).setOnClickListener(this);
flashButton = findViewById(R.id.flash_button);
flashButton.setOnClickListener(this);
settingsButton = findViewById(R.id.settings_button);
settingsButton.setOnClickListener(this);
setUpWorkflowModel();
}
/**
* use property animation by xml;
*
* @return
*/
private Animator getAnimationByXml() {
final int height = mPuppet.getLayoutParams().height;
final int width = mPuppet.getLayoutParams().width;
AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.animatorset);
//ValueAnimator usage:add AnimatorUpdateListener;
ArrayList<Animator> childAnimations = animatorSet.getChildAnimations();
((ValueAnimator) childAnimations.get(childAnimations.size() - 1))
.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float animatedValue = (float) valueAnimator.getAnimatedValue();
mPuppet.getLayoutParams().height = (int) (height * animatedValue);
mPuppet.getLayoutParams().width = (int) (width * animatedValue);
mPuppet.requestLayout();
}
});
animatorSet.setTarget(mPuppet);
return animatorSet;
}
private static void setViewStateListAnimator(View view, ViewNodeInfo viewNodeInfo) {
StateListAnimator stateListAnimator = viewNodeInfo.getStateListAnimator();
final int stateListAnimatorRes = viewNodeInfo.getStateListAnimatorRes();
if (stateListAnimator == null && stateListAnimatorRes == 0) {
return;
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
throw new IllegalStateException(
"MountState has a ViewNodeInfo with stateListAnimator, "
+ "however the current Android version doesn't support stateListAnimator on Views");
}
if (stateListAnimator == null) {
stateListAnimator =
AnimatorInflater.loadStateListAnimator(view.getContext(), stateListAnimatorRes);
}
view.setStateListAnimator(stateListAnimator);
}
private void checkIndicatorConfig(Context context) {
mIndicatorWidth = (mIndicatorWidth < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorWidth;
mIndicatorHeight =
(mIndicatorHeight < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorHeight;
mIndicatorMargin =
(mIndicatorMargin < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorMargin;
mAnimatorResId = (mAnimatorResId == 0) ? R.animator.scale_with_alpha : mAnimatorResId;
mAnimationOut = AnimatorInflater.loadAnimator(context, mAnimatorResId);
if (mAnimatorReverseResId == 0) {
mAnimationIn = AnimatorInflater.loadAnimator(context, mAnimatorResId);
mAnimationIn.setInterpolator(new ReverseInterpolator());
} else {
mAnimationIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId);
}
mIndicatorBackgroundResId = (mIndicatorBackgroundResId == 0) ? R.drawable.white_radius
: mIndicatorBackgroundResId;
mIndicatorUnselectedBackgroundResId =
(mIndicatorUnselectedBackgroundResId == 0) ? mIndicatorBackgroundResId
: mIndicatorUnselectedBackgroundResId;
}
private void checkIndicatorConfig(Context context) {
mIndicatorWidth = (mIndicatorWidth < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorWidth;
mIndicatorHeight =
(mIndicatorHeight < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorHeight;
mIndicatorMargin =
(mIndicatorMargin < 0) ? dip2px(DEFAULT_INDICATOR_WIDTH) : mIndicatorMargin;
mAnimatorResId = (mAnimatorResId == 0) ? R.animator.scale_with_alpha : mAnimatorResId;
mAnimationOut = AnimatorInflater.loadAnimator(context, mAnimatorResId);
if (mAnimatorReverseResId == 0) {
mAnimationIn = AnimatorInflater.loadAnimator(context, mAnimatorResId);
mAnimationIn.setInterpolator(new ReverseInterpolator());
} else {
mAnimationIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId);
}
mIndicatorBackgroundResId = (mIndicatorBackgroundResId == 0) ? R.drawable.white_radius
: mIndicatorBackgroundResId;
mIndicatorUnselectedBackgroundResId =
(mIndicatorUnselectedBackgroundResId == 0) ? mIndicatorBackgroundResId
: mIndicatorUnselectedBackgroundResId;
}
protected void setupProgressView() {
timerProgress = (ProgressBar) findViewById(R.id.progress_bar);
pointsTextView = (TextView) findViewById(R.id.points_value);
levelTextView = (TextView) findViewById(R.id.level_value);
TextView pointsLabel = (TextView) findViewById(R.id.points_label);
TextView levelsLabel = (TextView) findViewById(R.id.level_label);
// setting up fonts
Typeface avenir_black = Typeface.createFromAsset(getAssets(), "fonts/avenir_black.ttf");
Typeface avenir_book = Typeface.createFromAsset(getAssets(), "fonts/avenir_book.ttf");
pointsTextView.setTypeface(avenir_black);
levelTextView.setTypeface(avenir_black);
pointsLabel.setTypeface(avenir_book);
levelsLabel.setTypeface(avenir_book);
// setting up animations
pointAnim = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.points_animations);
pointAnim.setTarget(pointsTextView);
levelAnim = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.level_animations);
levelAnim.setTarget(levelTextView);
}
public Animator createShowUpAnimator(final View target) {
if (mHasCustomAnimationParams) {
final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_X, mShowUpStartXScale,
KEY_PREVIEW_SHOW_UP_END_SCALE);
final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_Y, mShowUpStartYScale,
KEY_PREVIEW_SHOW_UP_END_SCALE);
final AnimatorSet showUpAnimator = new AnimatorSet();
showUpAnimator.play(scaleXAnimator).with(scaleYAnimator);
showUpAnimator.setDuration(mShowUpDuration);
showUpAnimator.setInterpolator(DECELERATE_INTERPOLATOR);
return showUpAnimator;
}
final Animator animator = AnimatorInflater.loadAnimator(
target.getContext(), mShowUpAnimatorResId);
animator.setTarget(target);
animator.setInterpolator(DECELERATE_INTERPOLATOR);
return animator;
}
public Animator createDismissAnimator(final View target) {
if (mHasCustomAnimationParams) {
final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_X, mDismissEndXScale);
final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_Y, mDismissEndYScale);
final AnimatorSet dismissAnimator = new AnimatorSet();
dismissAnimator.play(scaleXAnimator).with(scaleYAnimator);
final int dismissDuration = Math.min(mDismissDuration, mLingerTimeout);
dismissAnimator.setDuration(dismissDuration);
dismissAnimator.setInterpolator(ACCELERATE_INTERPOLATOR);
return dismissAnimator;
}
final Animator animator = AnimatorInflater.loadAnimator(
target.getContext(), mDismissAnimatorResId);
animator.setTarget(target);
animator.setInterpolator(ACCELERATE_INTERPOLATOR);
return animator;
}
public Animator createDismissAnimator(final View target) {
if (mHasCustomAnimationParams) {
final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_X, mDismissEndXScale);
final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(
target, View.SCALE_Y, mDismissEndYScale);
final AnimatorSet dismissAnimator = new AnimatorSet();
dismissAnimator.play(scaleXAnimator).with(scaleYAnimator);
final int dismissDuration = Math.min(mDismissDuration, mLingerTimeout);
dismissAnimator.setDuration(dismissDuration);
dismissAnimator.setInterpolator(ACCELERATE_INTERPOLATOR);
return dismissAnimator;
}
final Animator animator = AnimatorInflater.loadAnimator(
target.getContext(), mDismissAnimatorResId);
animator.setTarget(target);
animator.setInterpolator(ACCELERATE_INTERPOLATOR);
return animator;
}
@Override
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
if (actionState != ItemTouchHelper.ACTION_STATE_DRAG) {
super.onSelectedChanged(viewHolder, actionState);
return;
}
if (dragAndDropCallback != null) {
dragAndDropCallback.onCellDragStarted(simpleRecyclerView, viewHolder.itemView, draggingItem, draggingItemPosition);
}
if (options.isDefaultEffectEnabled()) {
viewHolder.itemView.setSelected(true);
viewHolder.itemView.setAlpha(0.95f);
if (Build.VERSION.SDK_INT >= 21 && animator == null) {
animator = AnimatorInflater.loadStateListAnimator(viewHolder.itemView.getContext(), R.animator.raise);
viewHolder.itemView.setStateListAnimator(animator);
}
}
super.onSelectedChanged(viewHolder, actionState);
}
ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
setCardViewToFlat(card);
if (!Preferences.get(mContext).isShadowEnabled()) {
card.setCardElevation(0f);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
StateListAnimator stateListAnimator = AnimatorInflater
.loadStateListAnimator(mContext, R.animator.card_lift_long);
card.setStateListAnimator(stateListAnimator);
}
card.setOnClickListener(this);
card.setOnLongClickListener(this);
favorite.setOnClickListener(this);
}
public RecorderButton(Context context, AttributeSet attrs)
{
super(context, attrs);
mBtnAnim = AnimatorInflater.loadAnimator(getContext(), R.animator.recorder_btn_press_anim);
mBtnAnim.setTarget(this);
mDialogManager = new RecorderDialogManager(context);
mAudioManager = AudioManager.getInstance();
this.setOnLongClickListener(new OnLongClickListener()
{
@Override
public boolean onLongClick(View v)
{
// Log.e("TAG", "long click");
mBtnAnim.start();
isRecording = true;
mAudioManager.prepareAudio();
return false;
}
});
mAudioManager.setAudioStateListener(this);
}
public ProgramInfoViewBase(Context context, AttributeSet attrs) {
super(context, attrs);
setOrientation(LinearLayout.VERTICAL);
setGravity(Gravity.CENTER_VERTICAL);
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Objects.requireNonNull(inflater).inflate(getViewId(), this, true);
showTitleView = getRootView().findViewById(R.id.text_show_title);
showSubtitleView = getRootView().findViewById(R.id.text_show_subtitle);
showTimeView = getRootView().findViewById(R.id.text_show_time);
progressBarView = getRootView().findViewById(R.id.progressbar_show_progress);
updateShowInfoIntervalSeconds = getResources().getInteger(R.integer.view_program_info_update_show_info_interval_seconds);
updateShowTimeIntervalSeconds = getResources().getInteger(R.integer.view_program_info_update_show_time_interval_seconds);
showProgressAnimator = (ObjectAnimator) AnimatorInflater.loadAnimator(context,
R.animator.view_program_info_show_progress);
showProgressAnimator.setTarget(progressBarView);
}
/**
* use property animation by xml;
*
* @return
*/
private Animator getAnimationByXml() {
final int height = mPuppet.getLayoutParams().height;
final int width = mPuppet.getLayoutParams().width;
AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.animatorset);
//ValueAnimator usage:add AnimatorUpdateListener;
ArrayList<Animator> childAnimations = animatorSet.getChildAnimations();
((ValueAnimator) childAnimations.get(childAnimations.size() - 1))
.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float animatedValue = (float) valueAnimator.getAnimatedValue();
mPuppet.getLayoutParams().height = (int) (height * animatedValue);
mPuppet.getLayoutParams().width = (int) (width * animatedValue);
mPuppet.requestLayout();
}
});
animatorSet.setTarget(mPuppet);
return animatorSet;
}
/** Inflates an instance of MotionSpec from the given animator resource. */
@Nullable
public static MotionSpec createFromResource(@NonNull Context context, @AnimatorRes int id) {
try {
Animator animator = AnimatorInflater.loadAnimator(context, id);
if (animator instanceof AnimatorSet) {
AnimatorSet set = (AnimatorSet) animator;
return createSpecFromAnimators(set.getChildAnimations());
} else if (animator != null) {
List<Animator> animators = new ArrayList<>();
animators.add(animator);
return createSpecFromAnimators(animators);
} else {
return null;
}
} catch (Exception e) {
Log.w(TAG, "Can't load animation resource ID #0x" + Integer.toHexString(id), e);
return null;
}
}
public void onAnimatorSetTest(View view) {
// 获取屏幕宽度
int maxWidth = getWindowManager().getDefaultDisplay().getWidth();
ViewWrapper wrapper = new ViewWrapper(view, maxWidth);
AnimatorSet animatorSet = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.animator_set);
animatorSet.setTarget(wrapper);
animatorSet.start();
}
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
if (resId == 0) {
// TODO: Stop returning null.
return null;
}
final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator(
getContext(), resId);
if (animator != null) {
animator.setTarget(target);
}
return animator;
}
protected HandleAnimationManager(View handle, @AnimatorRes int grabAnimator, @AnimatorRes int releaseAnimator) {
if (grabAnimator != -1) {
this.grabAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(handle.getContext(), grabAnimator);
this.grabAnimator.setTarget(handle);
}
if (releaseAnimator != -1) {
this.releaseAnimator = (AnimatorSet) AnimatorInflater.loadAnimator(handle.getContext(), releaseAnimator);
this.releaseAnimator.setTarget(handle);
}
}
@Override
public Animator onCreateAnimator(int transit, boolean enter, int nextAnim) {
Animator anim = null;
if (showTransitionAnim) {
if (nextAnim != 0)
anim = AnimatorInflater.loadAnimator(getActivity(), nextAnim);
showTransitionAnim = false;
} else
anim = AnimatorInflater.loadAnimator(getActivity(), R.animator.none);
return anim;
}
private ObjectAnimator loadObjectAnimator(final int resId, final Object target) {
if (resId == 0) {
// TODO: Stop returning null.
return null;
}
final ObjectAnimator animator = (ObjectAnimator)AnimatorInflater.loadAnimator(
getContext(), resId);
if (animator != null) {
animator.setTarget(target);
}
return animator;
}
private void doViewPagerAnimation2(int pagerIndex) {
if (mPreViewPagerIndex > pagerIndex) {
// 从图3退到了图2,需要停止图3上的动画
mCurrentPager3Flag = false;
if (mCloudTransAnimationX1.isRunning()) {
mCloudTransAnimationX1.cancel();
mCloudTransAnimationY1.cancel();
mCloudTransAnimation2.cancel();
mCloudTransAnimation3.cancel();
mCloudTransAnimation4.cancel();
}
mNav3CloudImageView1.setVisibility(View.INVISIBLE);
mNav3CloudImageView2.setVisibility(View.INVISIBLE);
mNav3CloudImageView3.setVisibility(View.INVISIBLE);
mNav3CloudImageView4.setVisibility(View.INVISIBLE);
mRocketAnimationDrawable.stop();
} else {
// 是从图1前进到图2,所以要停止图1上的动画
mNav1TimeShowAnimationDrawable.stop();
mNavBatteryRotateAnimationSet.cancel();
mNav1BatteryImageView.setVisibility(View.INVISIBLE);
}
mNav2AnimationEverythingShow = (AnimatorSet) AnimatorInflater
.loadAnimator(NavigationWelcomeActivity.this,
R.anim.nav_2_everything_show);
mNav2MiddleEveryThingShowImageView.setVisibility(View.VISIBLE);
mNav2AnimationEverythingShow
.setTarget(mNav2MiddleEveryThingShowImageView);
mNav2AnimationEverythingShow.start();
mNavTopStaticAnimationSet.setTarget(mNav2TopStaticImageView);
mNavTopStaticAnimationSet.start();
}
public FunnyButton(Context context) {
super(context);
setPreventCornerOverlap(false);
setUseCompatPadding(true);
setClickable(true);
if (Build.VERSION.SDK_INT >= 21){
stateListAnimator = AnimatorInflater
.loadStateListAnimator(context, R.anim.card_ripple_touch);
setStateListAnimator(stateListAnimator);
}
setForeground(ContextCompat.getDrawable(context, R.drawable.card_ripple));
textView = new TextView(context);
}
public FunnyButton(Context context, AttributeSet attrs) {
super(context, attrs);
setPreventCornerOverlap(false);
setUseCompatPadding(true);
setClickable(true);
if (Build.VERSION.SDK_INT >= 21){
stateListAnimator = AnimatorInflater
.loadStateListAnimator(context, R.anim.card_ripple_touch);
setStateListAnimator(stateListAnimator);
}
setForeground(ContextCompat.getDrawable(context, R.drawable.card_ripple));
textView = new TextView(context);
initButton(context, attrs);
}
private void onAnswerResult(GamePlayViewModel.AnswerResult answerResult) {
if (answerResult.correct) {
TextView textView = findUsedWordTextViewByUsedWordId(answerResult.usedWordId);
if (textView != null) {
UsedWord uw = (UsedWord) textView.getTag();
if (getPreferences().grayscale()) {
uw.getAnswerLine().color = mGrayColor;
}
textView.setBackgroundColor(uw.getAnswerLine().color);
textView.setText(uw.getString());
textView.setTextColor(Color.WHITE);
textView.setPaintFlags(textView.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
Animator anim = AnimatorInflater.loadAnimator(this, R.animator.zoom_in_out);
anim.setTarget(textView);
anim.start();
}
mSoundPlayer.play(SoundPlayer.Sound.Correct);
}
else {
mLetterBoard.popStreakLine();
mSoundPlayer.play(SoundPlayer.Sound.Wrong);
}
}
/**
* Ports {@link android.view.View#setStateListAnimator(android.animation.StateListAnimator)}
* into components world. However, since the aforementioned view's method is available only on
* API 21 and above, calling this method on lower APIs will have no effect. On the legit
* versions, on the other hand, calling this method will lead to the component being wrapped
* into a view
*/
public T stateListAnimatorRes(@DrawableRes int resId) {
if (Build.VERSION.SDK_INT >= 26) {
// We cannot do it on the versions prior to Android 8.0 since there is a possible race
// condition when loading state list animators, thus we will avoid doing it off the UI
// thread
return stateListAnimator(
AnimatorInflater.loadStateListAnimator(mContext.getAndroidContext(), resId));
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mComponent.getOrCreateCommonProps().stateListAnimatorRes(resId);
}
return getThis();
}
public void flipOnVertical(View view)
{
View image = findViewById(R.id.some_image);
Animator anim = AnimatorInflater.loadAnimator(this, R.animator.flip_on_vertical);
anim.setTarget(image);
anim.start();
}