首页 > 代码库 > ValueAnimator

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 = http://www.mamicode.com/(Integer) animation.getAnimatedValue();""+value);
            }
        });
        va.start();
    }
}

 技术分享

ValueAnimator