Search in sources :

Example 61 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project afwall by ukanth.

the class RadialMenuWidget method onCloseAnimation.

private void onCloseAnimation() {
    // rotate = new RotateAnimation(360, 0, xPosition, yPosition);
    scale = new ScaleAnimation(1, 0, 1, 0, xPosition, yPosition);
    scale.setInterpolator(new AccelerateInterpolator());
    move = new TranslateAnimation(0, xSource - xPosition, 0, ySource - yPosition);
    spriteAnimation = new AnimationSet(true);
    // spriteAnimation.addAnimation(rotate);
    spriteAnimation.addAnimation(scale);
    spriteAnimation.addAnimation(move);
    spriteAnimation.setDuration(animationSpeed);
    startAnimation(spriteAnimation);
}
Also used : AccelerateInterpolator(android.view.animation.AccelerateInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AnimationSet(android.view.animation.AnimationSet) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 62 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project DMGameApp by xiaohaibin.

the class ClearEditText method shakeAnimation.

/**
 * 晃动动画
 *
 * @param counts 1秒钟晃动多少下
 * @return
 */
public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(1000);
    return translateAnimation;
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) TranslateAnimation(android.view.animation.TranslateAnimation) CycleInterpolator(android.view.animation.CycleInterpolator)

Example 63 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project open-event-android by fossasia.

the class AboutFragment method collapseExpandTextView.

@TargetApi(16)
void collapseExpandTextView() {
    // translation animation of event bar
    TranslateAnimation eventBarDownDirection = new TranslateAnimation(0, 0, -eventDescription.getHeight(), 0);
    eventBarDownDirection.setInterpolator(new LinearInterpolator());
    eventBarDownDirection.setDuration(300);
    TranslateAnimation eventBarUpDirection = new TranslateAnimation(0, 0, eventDescription.getHeight(), 0);
    eventBarUpDirection.setInterpolator(new LinearInterpolator());
    eventBarUpDirection.setDuration(300);
    // fading in or out of content
    AlphaAnimation contentAppear = new AlphaAnimation(0, 1);
    AlphaAnimation contentDisappear = new AlphaAnimation(1, 0);
    if (eventDescription.getVisibility() == View.GONE) {
        // it's collapsed - expand it.
        slidinDownPart.startAnimation(eventBarDownDirection);
        eventDescription.startAnimation(contentAppear);
        eventDescription.setVisibility(View.VISIBLE);
        descriptionImg.setImageResource(R.drawable.ic_expand_less_black_24dp);
    } else {
        // it's expanded - collapse it.
        slidinDownPart.startAnimation(eventBarUpDirection);
        eventDescription.startAnimation(contentDisappear);
        eventDescription.setVisibility(View.GONE);
        descriptionImg.setImageResource(R.drawable.ic_expand_more_black_24dp);
    }
}
Also used : LinearInterpolator(android.view.animation.LinearInterpolator) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) TargetApi(android.annotation.TargetApi)

Example 64 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project KL2 by jweihao.

the class ViewAnimationActivity method onViewClicked.

@OnClick({ R.id.button_alpha, R.id.button_rotate, R.id.button_translate, R.id.button_scale, R.id.button_set })
public void onViewClicked(View view) {
    switch(view.getId()) {
        // 透明
        case R.id.button_alpha:
            AlphaAnimation aa = new AlphaAnimation(0, 1);
            aa.setDuration(2000);
            mImageview.startAnimation(aa);
            break;
        // 旋转
        case R.id.button_rotate:
            // 参数为,旋转的起始角度,旋转中心点的坐标。(这里设置的是旋转参考系为自身中心点)
            RotateAnimation ra = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5F, RotateAnimation.RELATIVE_TO_SELF, 0.5F);
            ra.setDuration(2000);
            mImageview.startAnimation(ra);
            break;
        // 位移
        case R.id.button_translate:
            TranslateAnimation ta = new TranslateAnimation(0, 100, 0, 800);
            ta.setDuration(3000);
            // 使用位移来实现监听事件功能
            ta.setAnimationListener(new Animation.AnimationListener() {

                @Override
                public void onAnimationStart(Animation animation) {
                    Toast.makeText(ViewAnimationActivity.this, "开始 TranslateAnimation", Toast.LENGTH_SHORT).show();
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    Toast.makeText(ViewAnimationActivity.this, "结束 TranslateAnimation", Toast.LENGTH_SHORT).show();
                }

                // 通知动画的重复
                @Override
                public void onAnimationRepeat(Animation animation) {
                }
            });
            mImageview.startAnimation(ta);
            break;
        // 缩放
        case R.id.button_scale:
            // (设置参数缩放的中心点为自身中心点,从0放大到2倍)
            ScaleAnimation sa = new ScaleAnimation(0, 2, 0, 2, Animation.RELATIVE_TO_SELF, 0.5F, Animation.RELATIVE_TO_SELF, 0.5F);
            sa.setDuration(3000);
            mImageview.startAnimation(sa);
            break;
        // 动画集合,通过AnimationSet,可以将动画以组合的形式展现出来。
        case R.id.button_set:
            // 动画集合
            AnimationSet as = new AnimationSet(true);
            as.setDuration(3000);
            // 透明
            AlphaAnimation alpha = new AlphaAnimation(0, 1);
            alpha.setDuration(3000);
            as.addAnimation(alpha);
            // 位移
            TranslateAnimation translate = new TranslateAnimation(0, 100, 0, 800);
            translate.setDuration(3000);
            as.addAnimation(translate);
            mImageview.startAnimation(as);
            break;
        default:
            break;
    }
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) RotateAnimation(android.view.animation.RotateAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) AlphaAnimation(android.view.animation.AlphaAnimation) Animation(android.view.animation.Animation) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation) OnClick(butterknife.OnClick)

Example 65 with TranslateAnimation

use of android.view.animation.TranslateAnimation in project mixpanel-android by mixpanel.

the class InAppFragment method onAttach.

// It's safe to use onAttach(Activity) in API 23 as its implementation has not been changed.
// Bypass the Lint check for now.
@SuppressWarnings("deprecation")
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mParent = activity;
    if (null == mDisplayState) {
        cleanUp();
        return;
    }
    // We have to manually clear these Runnables in onStop in case they exist, since they
    // do illegal operations when onSaveInstanceState has been called already.
    mHandler = new Handler();
    mRemover = new Runnable() {

        public void run() {
            InAppFragment.this.remove();
        }
    };
    mDisplayMini = new Runnable() {

        @Override
        public void run() {
            mInAppView.setVisibility(View.VISIBLE);
            mInAppView.setOnTouchListener(new OnTouchListener() {

                @Override
                public boolean onTouch(View view, MotionEvent event) {
                    return InAppFragment.this.mDetector.onTouchEvent(event);
                }
            });
            final ImageView notifImage = (ImageView) mInAppView.findViewById(R.id.com_mixpanel_android_notification_image);
            final float heightPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 65, mParent.getResources().getDisplayMetrics());
            final TranslateAnimation translate = new TranslateAnimation(0, 0, heightPx, 0);
            translate.setInterpolator(new DecelerateInterpolator());
            translate.setDuration(200);
            mInAppView.startAnimation(translate);
            final ScaleAnimation scale = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, heightPx / 2, heightPx / 2);
            scale.setInterpolator(new SineBounceInterpolator());
            scale.setDuration(400);
            scale.setStartOffset(200);
            notifImage.startAnimation(scale);
        }
    };
    mDetector = new GestureDetector(activity, new GestureDetector.OnGestureListener() {

        @Override
        public boolean onDown(MotionEvent e) {
            return true;
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            if (velocityY > 0) {
                remove();
            }
            return true;
        }

        @Override
        public void onLongPress(MotionEvent e) {
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            return false;
        }

        @Override
        public void onShowPress(MotionEvent e) {
        }

        @Override
        public boolean onSingleTapUp(MotionEvent event) {
            final MiniInAppNotification inApp = (MiniInAppNotification) mDisplayState.getInAppNotification();
            JSONObject trackingProperties = null;
            final String uriString = inApp.getCtaUrl();
            if (uriString != null && uriString.length() > 0) {
                Uri uri;
                try {
                    uri = Uri.parse(uriString);
                } catch (IllegalArgumentException e) {
                    MPLog.i(LOGTAG, "Can't parse notification URI, will not take any action", e);
                    return true;
                }
                try {
                    Intent viewIntent = new Intent(Intent.ACTION_VIEW, uri);
                    mParent.startActivity(viewIntent);
                } catch (ActivityNotFoundException e) {
                    MPLog.i(LOGTAG, "User doesn't have an activity for notification URI " + uri);
                }
                try {
                    trackingProperties = new JSONObject();
                    trackingProperties.put("url", uriString);
                } catch (final JSONException e) {
                    MPLog.e(LOGTAG, "Can't put url into json properties");
                }
            }
            mMixpanel.getPeople().trackNotification("$campaign_open", inApp, trackingProperties);
            remove();
            return true;
        }
    });
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) OnTouchListener(android.view.View.OnTouchListener) Handler(android.os.Handler) TranslateAnimation(android.view.animation.TranslateAnimation) JSONException(org.json.JSONException) GestureDetector(android.view.GestureDetector) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Uri(android.net.Uri) MotionEvent(android.view.MotionEvent) ScaleAnimation(android.view.animation.ScaleAnimation) JSONObject(org.json.JSONObject) ActivityNotFoundException(android.content.ActivityNotFoundException) ImageView(android.widget.ImageView)

Aggregations

TranslateAnimation (android.view.animation.TranslateAnimation)229 Animation (android.view.animation.Animation)109 AlphaAnimation (android.view.animation.AlphaAnimation)90 AnimationSet (android.view.animation.AnimationSet)69 ScaleAnimation (android.view.animation.ScaleAnimation)44 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)30 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)27 View (android.view.View)22 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)22 TextView (android.widget.TextView)18 AnimationListener (android.view.animation.Animation.AnimationListener)17 LinearInterpolator (android.view.animation.LinearInterpolator)13 RotateAnimation (android.view.animation.RotateAnimation)13 ClipRectAnimation (android.view.animation.ClipRectAnimation)12 ListView (android.widget.ListView)12 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)12 ImageView (android.widget.ImageView)11 LayoutAnimationController (android.view.animation.LayoutAnimationController)8 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)8 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)8