<div id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:06a8b8fd-c295-4a01-b0a5-8c45dc57e6e8" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"><pre class="brush: java; gutter: true; first-line: 1; tab-size: 4; toolbar: true; width: 638px; height: 529px;" style=" width: 638px; height: 529px;overflow: auto;">class Ob { // 需要名为alpha的私有属性变量 private float alpha =0.0f; // 同样需要这样一个公有方法,否则对象里的值不会变化 public void setAlpha(float a) { alpha = a; } } private void test() { final Ob o = new Ob(); ObjectAnimator oa=ObjectAnimator.ofFloat(o, "alpha", 0f, 1f); oa.setDuration(3000); oa.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { //Log.i("update", ((Float) animation.getAnimatedValue()).toString()); Log.i("update", ""+o.alpha); } }); oa.start();
}</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div>