0
我試圖讓文本視圖逐個放大/縮小4次。它只有一次,然後就死了。動畫不重複
public class MainActivity extends Activity implements AnimationListener {
Animation zoomin, zoomout;
TextView text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text = (TextView) findViewById(R.id.text);
runOnUiThread(new Runnable() {
@Override
public void run() {
for (int i = 0; i < 4; i++) {
zoomin = AnimationUtils.loadAnimation(MainActivity.this,
R.anim.zoomin);
zoomin.setAnimationListener(MainActivity.this);
zoomout = AnimationUtils.loadAnimation(MainActivity.this,
R.anim.zoomout);
text.setAnimation(zoomin);
text.setAnimation(zoomout);
text.startAnimation(zoomin);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
}
@Override
public void onAnimationEnd(Animation animation) {
text.startAnimation(zoomout);
}
}
感謝您編輯答案sirko。 – baskar
upvote for answer,謝謝baskar – Siddharth
感謝喜歡Siddharth。我很高興該解決方案適合您。祝你今天愉快。 – baskar