public void hideToFromView() { if (vFrom != null) { AlphaAnimation animAlpha = new AlphaAnimation(1, 0); animAlpha.setDuration(AnimationDuration); vMask.startAnimation(animAlpha); int x = 0; int y = (screenHeight - statusBarHeight - screenWidth) / 2 + statusBarHeight; int[] location = new int[2]; vFrom.getLocationInWindow(location); int toX = location[0]; int toY = location[1]; float scale = (float) vFrom.getWidth() / (float) UIUtil.getScreenWidth(); ScaleAnimation animScale = new ScaleAnimation(1, scale, 1, scale); animScale.setDuration(AnimationDuration); TranslateAnimation animTrans = new TranslateAnimation(0, toX - x, 0, toY - y); animTrans.setDuration(AnimationDuration); AnimationSet animSet = new AnimationSet(true); animSet.addAnimation(animScale); animSet.addAnimation(animTrans); flImages.startAnimation(animSet); postDelayed( new Runnable() { @Override public void run() { setVisibility(View.GONE); } }, AnimationDuration); } else { setVisibility(View.GONE); } }
public void initWidgets() { imageA = (ImageView) findViewById(R.id.ivA); imageB = (ImageView) findViewById(R.id.ivB); showImageA(); sato0.setDuration(500); sato1.setDuration(500); sato0.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationRepeat(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { if (imageA.getVisibility() == View.VISIBLE) { imageA.setAnimation(null); showImageB(); imageB.startAnimation(sato1); } else { imageB.setAnimation(null); showImageA(); imageA.startAnimation(sato1); } } }); }
public static void postScaleAnimation(View v) { ScaleAnimation scaleAnimation1 = new ScaleAnimation( 1.0f, 0.5f, 1.0f, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleAnimation1.setDuration(200); ScaleAnimation scaleAnimation2 = new ScaleAnimation( 0.5f, 1.5f, 0.5f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleAnimation2.setDuration(100); AnimationSet set = new AnimationSet(true); set.addAnimation(scaleAnimation1); set.addAnimation(scaleAnimation2); v.startAnimation(set); }
public ViewSwaper(int mPosition, View vFront, View vBack, ViewGroup vgContainer, String axis) { this.mPosition = mPosition; this.vFront = vFront; this.vBack = vBack; this.vgContainer = vgContainer; this.axis = axis; largerAnimation = new ScaleAnimation( 0.4f, 1.0f, 0.4f, 1.0f, Animation.RELATIVE_TO_SELF, 0.2f, Animation.RELATIVE_TO_SELF, 0.5f); largerAnimation.setDuration(500); smallerAnimation = new ScaleAnimation( 1.0f, 0.6f, 1.0f, 0.6f, Animation.RELATIVE_TO_SELF, 0.2f, Animation.RELATIVE_TO_SELF, 0.5f); smallerAnimation.setDuration(500); }
/** * Shows the FAB and sets the FAB's translation. * * @param translationX translation X value * @param translationY translation Y value */ @Override public void show(float translationX, float translationY) { // Set FAB's translation setTranslation(translationX, translationY); // Only use scale animation if FAB is hidden if (getVisibility() != View.VISIBLE) { // Pivots indicate where the animation begins from float pivotX = getPivotX() + translationX; float pivotY = getPivotY() + translationY; ScaleAnimation anim; // If pivots are 0, that means the FAB hasn't been drawn yet so just use the // center of the FAB if (pivotX == 0 || pivotY == 0) { anim = new ScaleAnimation( 0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); } else { anim = new ScaleAnimation(0, 1, 0, 1, pivotX, pivotY); } // Animate FAB expanding anim.setDuration(FAB_ANIM_DURATION); anim.setInterpolator(getInterpolator()); startAnimation(anim); } setVisibility(View.VISIBLE); }
/** * 以中心为缩放中心 的缩放动画 * * @param v 执行动画的view * @param fromX * @param toX * @param fromY * @param toY * @param fillAfter * @param durationMillis * @return 返回 动画对象 */ public static ScaleAnimation scacle( View v, float fromX, float toX, float fromY, float toY, boolean fillAfter, long durationMillis) { if (sa == null) { sa = new ScaleAnimation( fromX, toX, fromY, toY, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); } sa.setFillAfter(fillAfter); sa.setDuration(durationMillis); v.startAnimation(sa); return sa; }
@Override public void onClick(View v) { if (currentState == FIRST_ROUND_BETTING || currentState == SECOND_ROUND_BETTING) { if (currentState == SECOND_ROUND_BETTING && trumpSuit == cardLead.getSuit()) { trumpSuit = -1; updateTrumpSuit(); // TODO tell player they can't choose the suit that was offered to bet on in the first // round } if (trumpSuit == -1) { ScaleAnimation scale = new ScaleAnimation((float) 1.1, (float) 1.1, (float) 1.2, (float) 1.2); scale.scaleCurrentDuration(5); chooseSuit.startAnimation(scale); return; } EuchreBet bet = new EuchreBet(trumpSuit, true, true); connection.write(currentState, bet.toString()); isBettingNow = false; playingView(); setButtonsEnabled(false); isTurn = false; cardSuggestedId = -1; } }
/** 初始化闪屏页的动画方法 */ private void initAnimotion() { // 设置动画集合 set = new AnimationSet(false); // 旋转动画 RotateAnimation rotate = new RotateAnimation( 0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotate.setDuration(1000); rotate.setFillAfter(true); // 设置动画结束后保持原状 // 缩放动画 ScaleAnimation scale = new ScaleAnimation( 0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scale.setDuration(1000); scale.setFillAfter(true); // 设置动画结束后保持原状 // 渐变动画 AlphaAnimation alpha = new AlphaAnimation(0, 1); alpha.setDuration(3000); alpha.setFillAfter(true); // 设置动画结束后保持原状 // 添加到动画集合中 set.addAnimation(rotate); set.addAnimation(scale); set.addAnimation(alpha); rl_spalash.startAnimation(set); }
/** Some simple animations run on user login */ private void animateUserWelcome() { mUserImage.setImageResource(mCurrentUser.getUserImageResource()); ViewUtils.setScale(mUserImage, 1); ScaleAnimation scale_in = new ScaleAnimation( 0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scale_in.setDuration(1000); scale_in.setFillAfter(true); scale_in.setInterpolator(new DecelerateInterpolator()); mUserImage.startAnimation(scale_in); final long button_scale_time = 1000; final long button_scale_increment_time = 250; // Animate the buttons coming in ViewUtils.animateButtonShow( mLitterButton, button_scale_time + (button_scale_increment_time * 0)); ViewUtils.animateButtonShow( mSearchButton, button_scale_time + (button_scale_increment_time * 1)); ViewUtils.animateButtonShow( mFollowersButton, button_scale_time + (button_scale_increment_time * 2)); ViewUtils.animateButtonShow( mSettingsButton, button_scale_time + (button_scale_increment_time * 3)); // Make the background of the button bar visible mButtonBar.setAlpha(1); }
public ScaleAnimation getScaleHeightAnimation(float start, float end) { ScaleAnimation animation = new ScaleAnimation(1.0f, 1.0f, start, end); animation.setDuration(1000); animation.setFillAfter(true); animation.setFillEnabled(true); animation.setFillBefore(true); return animation; }
/** * 生成动画 * * @param target GameItem */ private void animCreate(GameItem target) { ScaleAnimation sa = new ScaleAnimation( 0.1f, 1, 0.1f, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); sa.setDuration(100); target.setAnimation(null); target.getItemView().startAnimation(sa); }
public Animation createAnimation() { ScaleAnimation localScaleAnimation = new ScaleAnimation( this.fromXScale, this.toXScale, this.fromYScale, this.toYScale, 1, 0.5F, 1, 0.5F); localScaleAnimation.setFillAfter(true); localScaleAnimation.setInterpolator(new AccelerateInterpolator()); localScaleAnimation.setDuration(this.duration); return localScaleAnimation; }
public void ScalePic(Boolean isEnemy) { ScaleAnimation anim = new ScaleAnimation(0, 1, 0, 1); anim.setDuration(400); if (isEnemy) { EnemyImage.startAnimation(anim); } else { UserImage.startAnimation(anim); } }
/** Animation for the logo on app launch */ private void animateLogoIn() { ScaleAnimation fade_in = new ScaleAnimation( 0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); fade_in.setDuration(750); fade_in.setFillAfter(true); fade_in.setInterpolator(new DecelerateInterpolator()); mGlitterLogo.startAnimation(fade_in); }
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); WIDTH = w; HEIGHT = h; scaleAnimation = new ScaleAnimation(1.0f, zoomScale, 1.0f, zoomScale, w / 2, h / 2); scaleAnimation.setDuration(zoomDuration); scaleAnimation.setRepeatMode(Animation.REVERSE); scaleAnimation.setRepeatCount(1); }
public static Animation ScaleSmallLeftTop(Interpolator inter) { scaleAnim = new ScaleAnimation( 1.0f, 0, 1.0f, 0, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0); if (inter != null) { scaleAnim.setInterpolator(inter); } scaleAnim.setFillAfter(true); scaleAnim.setDuration(animDuration); return scaleAnim; }
@Override public void onStart() { super.onStart(); ScaleAnimation sc = new ScaleAnimation( 0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, .5f); sc.setInterpolator(new AnticipateOvershootInterpolator()); sc.setDuration(300); myfab.startAnimation(sc); vp.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.abc_slide_in_bottom)); }
/* * 开启动画,旋转,缩放 */ private void startAnimation() { AnimationSet set = new AnimationSet(false); // 旋转动画,以自身的中心点为枢轴,从0旋转到360度 RotateAnimation rotate = new RotateAnimation( 0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotate.setDuration(1000); // 动画持续的时间1s rotate.setFillAfter(true); // 是动画在结束之后保持该状态 // 缩放动画 ScaleAnimation scale = new ScaleAnimation( 0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scale.setDuration(1000); scale.setFillAfter(true); // 渐变动画 AlphaAnimation alpha = new AlphaAnimation(0f, 1f); alpha.setDuration(1000); alpha.setFillAfter(true); set.addAnimation(rotate); set.addAnimation(scale); set.addAnimation(alpha); set.setAnimationListener( new AnimationListener() { // 动画开始的时候回调 @Override public void onAnimationStart(Animation animation) {} // 动画重复播放的时候调用 @Override public void onAnimationRepeat(Animation animation) {} // 动画结束的时候调用,去跳转到新手引导的页面 @Override public void onAnimationEnd(Animation animation) { /*Intent intent = new Intent(SplashActivity.this, GuideActivity.class); startActivity(intent); finish();*/ jumpNextPage(); } }); rlRoot.startAnimation(set); }
private AnimationSet getAnimSet() { AnimationSet animSet = new AnimationSet(true); ScaleAnimation scale = new ScaleAnimation( 1f, 5f, 1, 5f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scale.setDuration(ANIMATION_PLAY_INTERVAL); AlphaAnimation alpha = new AlphaAnimation(1, 0); alpha.setDuration(ANIMATION_PLAY_INTERVAL); alpha.setStartOffset(0); animSet.addAnimation(scale); animSet.addAnimation(alpha); /* animSet.setRepeatCount(Animation.INFINITE); */ return animSet; }
private synchronized void scaleSmallView(View v) { ScaleAnimation mLitteAnimation = new ScaleAnimation( 1.0f, 0.9f, 1.0f, 0.9f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mLitteAnimation.setDuration(animTime); mLitteAnimation.setFillAfter(true); v.startAnimation(mLitteAnimation); }
public static ScaleAnimation getCenterScaleAnimation( float fromX, float toX, float fromY, float toY, int durationMillis) { ScaleAnimation scaleAnimation = new ScaleAnimation( fromX, toX, fromY, toY, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scaleAnimation.setDuration(durationMillis); return scaleAnimation; }
@Override public void onClick(View v) { // Show an animation indicating the card was selected ScaleAnimation scale = new ScaleAnimation((float) 1.2, (float) 1.2, (float) 1.2, (float) 1.2); scale.scaleCurrentDuration(5); v.startAnimation(scale); // Let the UI know which card was selected playerContext.setSelected(v.getId(), cardSuggestedId); for (int i = 0; i < cardHand.size(); i++) { if (cardHand.get(i).getIdNum() == v.getId()) { cardSelected = cardHand.get(i); } } }
/** Hides the FAB. */ @Override public void hide() { // Only use scale animation if FAB is visible if (getVisibility() == View.VISIBLE) { // Pivots indicate where the animation begins from float pivotX = getPivotX() + getTranslationX(); float pivotY = getPivotY() + getTranslationY(); // Animate FAB shrinking ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, pivotX, pivotY); anim.setDuration(FAB_ANIM_DURATION); anim.setInterpolator(getInterpolator()); startAnimation(anim); } setVisibility(View.INVISIBLE); }
public static Animation ScaleToBigVerticalOut(Interpolator inter) { scaleAnim = new ScaleAnimation( 1.0f, 1.0f, 1.0f, 0f, Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 0.5f); if (inter != null) { scaleAnim.setInterpolator(inter); } scaleAnim.setFillAfter(true); scaleAnim.setDuration(animDuration); return scaleAnim; }
private Animation exitRight() { final AnimationSet set = new AnimationSet(false); final RotateAnimation rotateOut = new RotateAnimation( 0, EXIT_ANGLE, Animation.RELATIVE_TO_SELF, EXIT_ROTATION_CENTER_X, Animation.RELATIVE_TO_SELF, EXIT_ROTATION_CENTER_Y); rotateOut.setDuration(ANIMATION_ROTATION_MILLIS); rotateOut.setStartOffset(ANIMATION_DURATION_MILLIS - ANIMATION_ROTATION_MILLIS); set.addAnimation(rotateOut); final ScaleAnimation scaleDown = new ScaleAnimation( 1, EXIT_SIZE, 1, EXIT_SIZE, Animation.RELATIVE_TO_SELF, EXIT_ROTATION_CENTER_X, Animation.RELATIVE_TO_SELF, EXIT_ROTATION_CENTER_Y); scaleDown.setDuration(ANIMATION_ROTATION_MILLIS); scaleDown.setStartOffset(ANIMATION_DURATION_MILLIS - ANIMATION_ROTATION_MILLIS); set.addAnimation(scaleDown); final TranslateAnimation slideX = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_PARENT, 0.3f, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0); slideX.setInterpolator(new AccelerateInterpolator()); slideX.setDuration(ANIMATION_DURATION_MILLIS); set.addAnimation(slideX); return set; }
@Override public void onResume() { mScaleAnimation = new ScaleAnimation(0, 1, 0, 1); mScaleAnimation.setDuration(500); mLayoutAnimationController = new LayoutAnimationController(mScaleAnimation, 0.5f); getListView().setLayoutAnimation(mLayoutAnimationController); super.onResume(); }
/** 开启动画 */ private void startAnim() { // 动画集合 AnimationSet set = new AnimationSet(false); // 旋转动画 RotateAnimation rotate = new RotateAnimation( 0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); rotate.setDuration(2000); // 旋转时间 rotate.setFillAfter(true); // 保持动画状态 // 缩放动画 ScaleAnimation scale = new ScaleAnimation( 0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); scale.setDuration(2000); // 时间 scale.setFillAfter(true); // 保持动画状态 // 渐变动画 AlphaAnimation alpha = new AlphaAnimation(0, 1); alpha.setDuration(2000); // 时间 alpha.setFillAfter(true); // 保持动画状态 set.addAnimation(rotate); set.addAnimation(scale); set.addAnimation(alpha); // 设定动画监听 set.setAnimationListener( new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { // 动画结束后跳转到GuideActivity中 jumpNextPage(); } @Override public void onAnimationRepeat(Animation animation) {} }); rlRoot.startAnimation(set); }
public static ScaleAnimation getScaleAnimation( float fromX, float toX, float fromY, float toY, float pivotX, float pivotY, int durationMillis) { ScaleAnimation scaleAnimation = new ScaleAnimation( fromX, toX, fromY, toY, Animation.RELATIVE_TO_SELF, pivotX, Animation.RELATIVE_TO_SELF, pivotY); scaleAnimation.setDuration(durationMillis); return scaleAnimation; }
public void showPicFromPosition( final String content, final Bitmap placeHolder, final int x, final int y, final int width) { initView(); setVisibility(View.VISIBLE); iv.setVisibility(View.INVISIBLE); ivPlaceHolder.setImageBitmap(placeHolder); final int size = Math.min(screenHeight, screenWidth); new Thread() { public void run() { final Bitmap bmp = Qr.bitmap(content, size); post( new Runnable() { @Override public void run() { iv.setImageBitmap(bmp); iv.setVisibility(View.VISIBLE); } }); }; }.start(); AlphaAnimation animAlpha = new AlphaAnimation(0, 1); animAlpha.setDuration(AnimationDuration); vMask.startAnimation(animAlpha); int toX = 0; int toY = (screenHeight - statusBarHeight - screenWidth) / 2 + statusBarHeight; int toWidth = UIUtil.getScreenWidth(); float scale = (float) width / (float) toWidth; ScaleAnimation animScale = new ScaleAnimation(scale, 1, scale, 1); animScale.setDuration(AnimationDuration); TranslateAnimation animTrans = new TranslateAnimation(x - toX, 0, y - toY, 0); animTrans.setDuration(AnimationDuration); AnimationSet animSet = new AnimationSet(true); animSet.setFillBefore(true); animSet.setDuration(AnimationDuration); animSet.addAnimation(animScale); animSet.addAnimation(animTrans); flImages.startAnimation(animSet); }
private Animation enterLeft() { final AnimationSet set = new AnimationSet(false); final RotateAnimation rotateIn = new RotateAnimation( -EXIT_ANGLE, 0, Animation.RELATIVE_TO_SELF, EXIT_ROTATION_CENTER_X, Animation.RELATIVE_TO_SELF, EXIT_ROTATION_CENTER_Y); rotateIn.setDuration(ANIMATION_ROTATION_MILLIS); set.addAnimation(rotateIn); final ScaleAnimation scaleUp = new ScaleAnimation( EXIT_SIZE, 1, EXIT_SIZE, 1, Animation.RELATIVE_TO_SELF, EXIT_ROTATION_CENTER_X, Animation.RELATIVE_TO_SELF, EXIT_ROTATION_CENTER_Y); scaleUp.setDuration(ANIMATION_ROTATION_MILLIS); set.addAnimation(scaleUp); final TranslateAnimation slideX = new TranslateAnimation( Animation.RELATIVE_TO_PARENT, -1.3f, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0, Animation.RELATIVE_TO_PARENT, 0); slideX.setDuration(ANIMATION_DURATION_MILLIS); set.addAnimation(slideX); return set; }