Search in sources :

Example 31 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project XRecyclerView by jianghejie.

the class BallZigZagDeflectIndicator method createAnimation.

@Override
public List<Animator> createAnimation() {
    List<Animator> animators = new ArrayList<>();
    float startX = getWidth() / 6;
    float startY = getWidth() / 6;
    for (int i = 0; i < 2; i++) {
        final int index = i;
        ValueAnimator translateXAnim = ValueAnimator.ofFloat(startX, getWidth() - startX, startX, getWidth() - startX, startX);
        if (i == 1) {
            translateXAnim = ValueAnimator.ofFloat(getWidth() - startX, startX, getWidth() - startX, startX, getWidth() - startX);
        }
        ValueAnimator translateYAnim = ValueAnimator.ofFloat(startY, startY, getHeight() - startY, getHeight() - startY, startY);
        if (i == 1) {
            translateYAnim = ValueAnimator.ofFloat(getHeight() - startY, getHeight() - startY, startY, startY, getHeight() - startY);
        }
        translateXAnim.setDuration(2000);
        translateXAnim.setInterpolator(new LinearInterpolator());
        translateXAnim.setRepeatCount(-1);
        translateXAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                translateX[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        translateXAnim.start();
        translateYAnim.setDuration(2000);
        translateYAnim.setInterpolator(new LinearInterpolator());
        translateYAnim.setRepeatCount(-1);
        translateYAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                translateY[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        translateYAnim.start();
        animators.add(translateXAnim);
        animators.add(translateYAnim);
    }
    return animators;
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) LinearInterpolator(android.view.animation.LinearInterpolator) ArrayList(java.util.ArrayList) ValueAnimator(android.animation.ValueAnimator)

Example 32 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project XRecyclerView by jianghejie.

the class CubeTransitionIndicator method createAnimation.

@Override
public List<Animator> createAnimation() {
    List<Animator> animators = new ArrayList<>();
    float startX = getWidth() / 5;
    float startY = getHeight() / 5;
    for (int i = 0; i < 2; i++) {
        final int index = i;
        translateX[index] = startX;
        ValueAnimator translationXAnim = ValueAnimator.ofFloat(startX, getWidth() - startX, getWidth() - startX, startX, startX);
        if (i == 1) {
            translationXAnim = ValueAnimator.ofFloat(getWidth() - startX, startX, startX, getWidth() - startX, getWidth() - startX);
        }
        translationXAnim.setInterpolator(new LinearInterpolator());
        translationXAnim.setDuration(1600);
        translationXAnim.setRepeatCount(-1);
        translationXAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                translateX[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        translationXAnim.start();
        translateY[index] = startY;
        ValueAnimator translationYAnim = ValueAnimator.ofFloat(startY, startY, getHeight() - startY, getHeight() - startY, startY);
        if (i == 1) {
            translationYAnim = ValueAnimator.ofFloat(getHeight() - startY, getHeight() - startY, startY, startY, getHeight() - startY);
        }
        translationYAnim.setDuration(1600);
        translationYAnim.setInterpolator(new LinearInterpolator());
        translationYAnim.setRepeatCount(-1);
        translationYAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                translateY[index] = (float) animation.getAnimatedValue();
                postInvalidate();
            }
        });
        translationYAnim.start();
        animators.add(translationXAnim);
        animators.add(translationYAnim);
    }
    ValueAnimator scaleAnim = ValueAnimator.ofFloat(1, 0.5f, 1, 0.5f, 1);
    scaleAnim.setDuration(1600);
    scaleAnim.setInterpolator(new LinearInterpolator());
    scaleAnim.setRepeatCount(-1);
    scaleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            scaleFloat = (float) animation.getAnimatedValue();
            postInvalidate();
        }
    });
    scaleAnim.start();
    ValueAnimator rotateAnim = ValueAnimator.ofFloat(0, 180, 360, 1.5f * 360, 2 * 360);
    rotateAnim.setDuration(1600);
    rotateAnim.setInterpolator(new LinearInterpolator());
    rotateAnim.setRepeatCount(-1);
    rotateAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            degrees = (float) animation.getAnimatedValue();
            postInvalidate();
        }
    });
    rotateAnim.start();
    animators.add(scaleAnim);
    animators.add(rotateAnim);
    return animators;
}
Also used : Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) LinearInterpolator(android.view.animation.LinearInterpolator) ArrayList(java.util.ArrayList) ValueAnimator(android.animation.ValueAnimator) Paint(android.graphics.Paint)

Example 33 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project LoadingView by ldoublem.

the class LVChromeLogo method initPaint.

private void initPaint() {
    evaluator = new ArgbEvaluator();
    mPaintRed = new Paint();
    mPaintRed.setAntiAlias(true);
    mPaintRed.setStyle(Paint.Style.FILL);
    mPaintRed.setColor(Color.rgb(211, 57, 53));
    mPaintYellow = new Paint();
    mPaintYellow.setAntiAlias(true);
    mPaintYellow.setStyle(Paint.Style.FILL);
    mPaintYellow.setColor(Color.rgb(253, 197, 53));
    mPaintGreen = new Paint();
    mPaintGreen.setAntiAlias(true);
    mPaintGreen.setStyle(Paint.Style.FILL);
    mPaintGreen.setColor(Color.rgb(27, 147, 76));
    mPaintBulue = new Paint();
    mPaintBulue.setAntiAlias(true);
    mPaintBulue.setStyle(Paint.Style.FILL);
    mPaintBulue.setColor(Color.rgb(61, 117, 242));
    mPaintWhite = new Paint();
    mPaintWhite.setAntiAlias(true);
    mPaintWhite.setStyle(Paint.Style.FILL);
    mPaintWhite.setColor(Color.WHITE);
    mPaintLine = new Paint();
    mPaintLine.setAntiAlias(true);
    mPaintLine.setStyle(Paint.Style.FILL);
    mPaintLine.setColor(Color.argb(30, 0, 0, 0));
    mProgerssRotateAnim = new RotateAnimation(0f, 360f, android.view.animation.Animation.RELATIVE_TO_SELF, 0.5f, android.view.animation.Animation.RELATIVE_TO_SELF, 0.5f);
    mProgerssRotateAnim.setRepeatCount(-1);
    //不停顿
    mProgerssRotateAnim.setInterpolator(new LinearInterpolator());
    //停在最后
    mProgerssRotateAnim.setFillAfter(true);
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) LinearInterpolator(android.view.animation.LinearInterpolator) ArgbEvaluator(android.animation.ArgbEvaluator) Paint(android.graphics.Paint)

Example 34 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project FastDev4Android by jiangqqlmj.

the class PullToRefreshListView method init.

private void init(Context context) {
    mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mFlipAnimation.setInterpolator(new LinearInterpolator());
    mFlipAnimation.setDuration(250);
    mFlipAnimation.setFillAfter(true);
    mReverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
    mReverseFlipAnimation.setDuration(250);
    mReverseFlipAnimation.setFillAfter(true);
    mRefreshView = (LinearLayout) View.inflate(context, R.layout.pull_to_refresh_header, null);
    mRefreshViewText = (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_text);
    mRefreshViewImage = (ImageView) mRefreshView.findViewById(R.id.pull_to_refresh_image);
    mRefreshViewProgress = (ProgressBar) mRefreshView.findViewById(R.id.pull_to_refresh_progress);
    mRefreshViewLastUpdated = (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_updated_at);
    mRefreshState = PULL_TO_REFRESH;
    //设置下拉最小的高度为50
    mRefreshViewImage.setMinimumHeight(50);
    setFadingEdgeLength(0);
    setHeaderDividersEnabled(false);
    //把refreshview加入到listview的头部
    addHeaderView(mRefreshView);
    super.setOnScrollListener(this);
    mRefreshView.setOnClickListener(this);
    mRefreshView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    mRefreshViewHeight = mRefreshView.getMeasuredHeight();
    mRefreshOriginalTopPadding = -mRefreshViewHeight;
    resetHeaderPadding();
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) LinearInterpolator(android.view.animation.LinearInterpolator)

Example 35 with LinearInterpolator

use of android.view.animation.LinearInterpolator in project android-common by Trinea.

the class DropDownListView method initDropDownStyle.

/**
     * init drop down style, only init once
     */
private void initDropDownStyle() {
    if (headerLayout != null) {
        if (isDropDownStyle) {
            addHeaderView(headerLayout);
        } else {
            removeHeaderView(headerLayout);
        }
        return;
    }
    if (!isDropDownStyle) {
        return;
    }
    headerReleaseMinDistance = context.getResources().getDimensionPixelSize(R.dimen.drop_down_list_header_release_min_distance);
    flipAnimation = new RotateAnimation(0, 180, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    flipAnimation.setInterpolator(new LinearInterpolator());
    flipAnimation.setDuration(250);
    flipAnimation.setFillAfter(true);
    reverseFlipAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
    reverseFlipAnimation.setInterpolator(new LinearInterpolator());
    reverseFlipAnimation.setDuration(250);
    reverseFlipAnimation.setFillAfter(true);
    headerDefaultText = context.getString(R.string.drop_down_list_header_default_text);
    headerPullText = context.getString(R.string.drop_down_list_header_pull_text);
    headerReleaseText = context.getString(R.string.drop_down_list_header_release_text);
    headerLoadingText = context.getString(R.string.drop_down_list_header_loading_text);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    headerLayout = (RelativeLayout) inflater.inflate(R.layout.drop_down_list_header, this, false);
    headerText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_default_text);
    headerImage = (ImageView) headerLayout.findViewById(R.id.drop_down_list_header_image);
    headerProgressBar = (ProgressBar) headerLayout.findViewById(R.id.drop_down_list_header_progress_bar);
    headerSecondText = (TextView) headerLayout.findViewById(R.id.drop_down_list_header_second_text);
    headerLayout.setClickable(true);
    headerLayout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onDropDown();
        }
    });
    headerText.setText(headerDefaultText);
    addHeaderView(headerLayout);
    measureHeaderLayout(headerLayout);
    headerOriginalHeight = headerLayout.getMeasuredHeight();
    headerOriginalTopPadding = headerLayout.getPaddingTop();
    currentHeaderStatus = HEADER_STATUS_CLICK_TO_LOAD;
}
Also used : RotateAnimation(android.view.animation.RotateAnimation) LinearInterpolator(android.view.animation.LinearInterpolator) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) View(android.view.View) ListView(android.widget.ListView)

Aggregations

LinearInterpolator (android.view.animation.LinearInterpolator)217 ValueAnimator (android.animation.ValueAnimator)65 Animator (android.animation.Animator)42 ObjectAnimator (android.animation.ObjectAnimator)39 Paint (android.graphics.Paint)30 ArrayList (java.util.ArrayList)28 AlphaAnimation (android.view.animation.AlphaAnimation)27 RotateAnimation (android.view.animation.RotateAnimation)24 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)22 PropertyValuesHolder (android.animation.PropertyValuesHolder)18 Animatable (android.graphics.drawable.Animatable)17 View (android.view.View)17 Animation (android.view.animation.Animation)17 Transformation (android.view.animation.Transformation)17 AnimatorSet (android.animation.AnimatorSet)14 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)14 TranslateAnimation (android.view.animation.TranslateAnimation)12 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)11 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)9 AnimationListener (android.view.animation.Animation.AnimationListener)8