ValueAnimator

import android.animation.ValueAnimator;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final TextView tv = (TextView) findViewById(R.id.tv_values);
        ValueAnimator va =  ValueAnimator.ofInt(0,100);
        va.setDuration(15000);
        va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                Integer value = (Integer) animation.getAnimatedValue();
                tv.setText(""+value);
            }
        });
        va.start();
    }
}

 

posted on 2017-02-24 10:32  LoaderMan  阅读(127)  评论(0编辑  收藏  举报

导航