Search in sources :

Example 16 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project WilliamChart by diogobernardino.

the class LineCardOne method show.

@Override
public void show(Runnable action) {
    super.show(action);
    // Tooltip
    mTip = new Tooltip(mContext, R.layout.linechart_three_tooltip, R.id.value);
    ((TextView) mTip.findViewById(R.id.value)).setTypeface(Typeface.createFromAsset(mContext.getAssets(), "OpenSans-Semibold.ttf"));
    mTip.setVerticalAlignment(Tooltip.Alignment.BOTTOM_TOP);
    mTip.setDimensions((int) Tools.fromDpToPx(58), (int) Tools.fromDpToPx(25));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        mTip.setEnterAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 1), PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f), PropertyValuesHolder.ofFloat(View.SCALE_X, 1f)).setDuration(200);
        mTip.setExitAnimation(PropertyValuesHolder.ofFloat(View.ALPHA, 0), PropertyValuesHolder.ofFloat(View.SCALE_Y, 0f), PropertyValuesHolder.ofFloat(View.SCALE_X, 0f)).setDuration(200);
        mTip.setPivotX(Tools.fromDpToPx(65) / 2);
        mTip.setPivotY(Tools.fromDpToPx(25));
    }
    mChart.setTooltips(mTip);
    // Data
    LineSet dataset = new LineSet(mLabels, mValues[0]);
    dataset.setColor(Color.parseColor("#758cbb")).setFill(Color.parseColor("#2d374c")).setDotsColor(Color.parseColor("#758cbb")).setThickness(4).setDashed(new float[] { 10f, 10f }).beginAt(5);
    mChart.addData(dataset);
    dataset = new LineSet(mLabels, mValues[0]);
    dataset.setColor(Color.parseColor("#b3b5bb")).setFill(Color.parseColor("#2d374c")).setDotsColor(Color.parseColor("#ffc755")).setThickness(4).endAt(6);
    mChart.addData(dataset);
    // Chart
    mChart.setBorderSpacing(Tools.fromDpToPx(15)).setAxisBorderValues(0, 20).setYLabels(AxisRenderer.LabelPosition.NONE).setLabelsColor(Color.parseColor("#6a84c3")).setXAxis(false).setYAxis(false);
    mBaseAction = action;
    Runnable chartAction = new Runnable() {

        @Override
        public void run() {
            mBaseAction.run();
            mTip.prepare(mChart.getEntriesArea(0).get(3), mValues[0][3]);
            mChart.showTooltip(mTip, true);
        }
    };
    Animation anim = new Animation().setEasing(new BounceInterpolator()).setEndAction(chartAction);
    mChart.show(anim);
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) Tooltip(com.db.chart.tooltip.Tooltip) Animation(com.db.chart.animation.Animation) TextView(android.widget.TextView) LineSet(com.db.chart.model.LineSet)

Example 17 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project ViewAnimator by florent37.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    image = (ImageView) findViewById(R.id.image);
    mountain = (ImageView) findViewById(R.id.mountain);
    text = (TextView) findViewById(R.id.text);
    percent = (TextView) findViewById(R.id.percent);
    findViewById(R.id.parallel).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            animateParallel();
        }
    });
    findViewById(R.id.mountain).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            simpleAnimation();
        }
    });
    findViewById(R.id.sequentially).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            animateSequentially();
        }
    });
    findViewById(R.id.enhanced).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int random = new Random().nextInt(10);
            final ViewGroup viewGroup = (ViewGroup) v.getParent();
            final ImageView imageView = new ImageView(v.getContext());
            imageView.setImageResource(R.mipmap.ic_launcher);
            viewGroup.addView(imageView);
            AnimationBuilder builder;
            switch(random) {
                case 0:
                    builder = ViewAnimator.animate(imageView).shake().interpolator(new LinearInterpolator());
                    break;
                case 1:
                    builder = ViewAnimator.animate(imageView).bounceIn().interpolator(new BounceInterpolator());
                    break;
                case 2:
                    builder = ViewAnimator.animate(imageView).flash().repeatCount(4);
                    break;
                case 3:
                    builder = ViewAnimator.animate(imageView).flipHorizontal();
                    break;
                case 4:
                    builder = ViewAnimator.animate(imageView).wave().duration(5000);
                    break;
                case 5:
                    builder = ViewAnimator.animate(imageView).tada();
                    break;
                case 6:
                    builder = ViewAnimator.animate(imageView).pulse();
                    break;
                case 7:
                    builder = ViewAnimator.animate(imageView).standUp();
                    break;
                case 8:
                    builder = ViewAnimator.animate(imageView).swing();
                    break;
                default:
                    builder = ViewAnimator.animate(imageView).wobble();
                    break;
            }
            builder.onStop(new AnimationListener.Stop() {

                @Override
                public void onStop() {
                    viewGroup.removeView(imageView);
                }
            }).start();
        }
    });
    findViewById(R.id.path).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Path path = new Path();
            path.moveTo(START_POINT[0], START_POINT[1]);
            path.quadTo(RIGHT_CONTROL_POINT[0], RIGHT_CONTROL_POINT[1], BOTTOM_POINT[0], BOTTOM_POINT[1]);
            path.quadTo(LEFT_CONTROL_POINT[0], LEFT_CONTROL_POINT[1], START_POINT[0], START_POINT[1]);
            path.close();
            ViewAnimator.animate(v).path(path).repeatCount(2).start();
        }
    });
    findViewById(R.id.svgPath).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ViewAnimator.animate(v).svgPath(SVG_PATH).duration(10000).repeatCount(3).start();
            final View btnWave = findViewById(R.id.wave);
            btnWave.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    ViewAnimator.animate(btnWave).wave().duration(3000).start();
                }
            });
            final View btnShake = findViewById(R.id.shake);
            btnShake.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    ViewAnimator.animate(btnShake).shake().duration(3000).start();
                }
            });
        }
    });
}
Also used : Path(android.graphics.Path) ViewGroup(android.view.ViewGroup) BounceInterpolator(android.view.animation.BounceInterpolator) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Random(java.util.Random) LinearInterpolator(android.view.animation.LinearInterpolator) ImageView(android.widget.ImageView) AnimationBuilder(com.github.florent37.viewanimator.AnimationBuilder) AnimationListener(com.github.florent37.viewanimator.AnimationListener)

Example 18 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project android-viewbadger by jgilfelt.

the class DemoActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final TabHost tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec("demos").setIndicator("Badge Demos").setContent(R.id.tab1));
    tabHost.addTab(tabHost.newTabSpec("adapter").setIndicator("List Adapter").setContent(R.id.tab2));
    tabHost.addTab(tabHost.newTabSpec("tests").setIndicator("Layout Tests").setContent(R.id.tab3));
    // *** default badge ***
    View target = findViewById(R.id.default_target);
    BadgeView badge = new BadgeView(this, target);
    badge.setText("1");
    badge.show();
    // *** set position ***
    btnPosition = (Button) findViewById(R.id.position_target);
    badge1 = new BadgeView(this, btnPosition);
    badge1.setText("12");
    badge1.setBadgePosition(BadgeView.POSITION_CENTER);
    btnPosition.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge1.toggle();
        }
    });
    // *** badge/text size & colour ***
    btnColour = (Button) findViewById(R.id.colour_target);
    badge2 = new BadgeView(this, btnColour);
    badge2.setText("New!");
    badge2.setTextColor(Color.BLUE);
    badge2.setBadgeBackgroundColor(Color.YELLOW);
    badge2.setTextSize(12);
    btnColour.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge2.toggle();
        }
    });
    // *** default animation ***
    btnAnim1 = (Button) findViewById(R.id.anim1_target);
    badge3 = new BadgeView(this, btnAnim1);
    badge3.setText("84");
    btnAnim1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge3.toggle(true);
        }
    });
    // *** custom animation ***
    btnAnim2 = (Button) findViewById(R.id.anim2_target);
    badge4 = new BadgeView(this, btnAnim2);
    badge4.setText("123");
    badge4.setBadgePosition(BadgeView.POSITION_TOP_LEFT);
    badge4.setBadgeMargin(15, 10);
    badge4.setBadgeBackgroundColor(Color.parseColor("#A4C639"));
    btnAnim2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            TranslateAnimation anim = new TranslateAnimation(-100, 0, 0, 0);
            anim.setInterpolator(new BounceInterpolator());
            anim.setDuration(1000);
            badge4.toggle(anim, null);
        }
    });
    // *** custom background ***
    btnCustom = (Button) findViewById(R.id.custom_target);
    badge5 = new BadgeView(this, btnCustom);
    badge5.setText("37");
    badge5.setBackgroundResource(R.drawable.badge_ifaux);
    badge5.setTextSize(16);
    btnCustom.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge5.toggle(true);
        }
    });
    // *** clickable badge ***
    btnClick = (Button) findViewById(R.id.click_target);
    badge6 = new BadgeView(this, btnClick);
    badge6.setText("click me");
    badge6.setBadgeBackgroundColor(Color.BLUE);
    badge6.setTextSize(16);
    badge6.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Toast.makeText(DemoActivity.this, "clicked badge", Toast.LENGTH_SHORT).show();
        }
    });
    btnClick.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge6.toggle();
        }
    });
    // *** tab ***
    TabWidget tabs = (TabWidget) findViewById(android.R.id.tabs);
    btnTab = (Button) findViewById(R.id.tab_btn);
    badge7 = new BadgeView(this, tabs, 0);
    badge7.setText("5");
    btnTab.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            badge7.toggle();
        }
    });
    // *** increment ***
    btnIncrement = (Button) findViewById(R.id.increment_target);
    badge8 = new BadgeView(this, btnIncrement);
    badge8.setText("0");
    btnIncrement.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (badge8.isShown()) {
                badge8.increment(1);
            } else {
                badge8.show();
            }
        }
    });
    // *** list adapter ****
    listDemo = (ListView) findViewById(R.id.tab2);
    listDemo.setAdapter(new BadgeAdapter(this));
}
Also used : TabHost(android.widget.TabHost) BounceInterpolator(android.view.animation.BounceInterpolator) BadgeView(com.readystatesoftware.viewbadger.BadgeView) OnClickListener(android.view.View.OnClickListener) TranslateAnimation(android.view.animation.TranslateAnimation) TabWidget(android.widget.TabWidget) TextView(android.widget.TextView) BadgeView(com.readystatesoftware.viewbadger.BadgeView) View(android.view.View) ListView(android.widget.ListView)

Example 19 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project Android-Developers-Samples by johnjohndoe.

the class CardActionButton method onTouchEvent.

@Override
public boolean onTouchEvent(MotionEvent event) {
    switch(event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            setPressed(true);
            animate().scaleX(0.98f).scaleY(0.98f).alpha(0.8f).setDuration(100).setInterpolator(new DecelerateInterpolator());
            break;
        case MotionEvent.ACTION_UP:
            animate().scaleX(1.0f).scaleY(1.f).alpha(1.0f).setDuration(50).setInterpolator(new BounceInterpolator());
            break;
        case MotionEvent.ACTION_CANCEL:
            animate().scaleX(1.0f).scaleY(1.f).alpha(1.0f).setDuration(50).setInterpolator(new BounceInterpolator());
            break;
    }
    return super.onTouchEvent(event);
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) BounceInterpolator(android.view.animation.BounceInterpolator)

Example 20 with BounceInterpolator

use of android.view.animation.BounceInterpolator in project nmid-headline by miao1007.

the class PullUpLayout method setupView.

private void setupView() {
    // 这个Interpolator你可以设置别的 我这里选择的是有弹跳效果的Interpolator
    Interpolator polator = new BounceInterpolator();
    mScroller = new Scroller(mContext, polator);
    mScreenHeigh = getScreenHeight(mContext);
    mScreenWidth = getScreenWidth(mContext);
    // 这里你一定要设置成透明背景,不然会影响你看到底层布局
    this.setBackgroundColor(Color.argb(0, 0, 0, 0));
    mImgView = new ImageView(mContext);
    mImgView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    // 填充整个屏幕
    mImgView.setScaleType(ImageView.ScaleType.FIT_XY);
    // 默认背景
    mImgView.setImageResource(R.drawable.bg_welcome);
    addView(mImgView);
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) BounceInterpolator(android.view.animation.BounceInterpolator) Interpolator(android.view.animation.Interpolator) Scroller(android.widget.Scroller) ImageView(android.widget.ImageView)

Aggregations

BounceInterpolator (android.view.animation.BounceInterpolator)30 View (android.view.View)8 AccelerateInterpolator (android.view.animation.AccelerateInterpolator)6 ImageView (android.widget.ImageView)6 ObjectAnimator (android.animation.ObjectAnimator)5 DecelerateInterpolator (android.view.animation.DecelerateInterpolator)5 LinearInterpolator (android.view.animation.LinearInterpolator)5 TextView (android.widget.TextView)5 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)4 AnticipateInterpolator (android.view.animation.AnticipateInterpolator)4 AnticipateOvershootInterpolator (android.view.animation.AnticipateOvershootInterpolator)4 Interpolator (android.view.animation.Interpolator)4 OvershootInterpolator (android.view.animation.OvershootInterpolator)4 Scroller (android.widget.Scroller)4 Animator (android.animation.Animator)3 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 Animation (com.db.chart.animation.Animation)3 ValueAnimator (android.animation.ValueAnimator)2 SuppressLint (android.annotation.SuppressLint)2 DisplayMetrics (android.util.DisplayMetrics)2