我试图使用TranslateAnimation
上ImageView
,但ImageView
根本不会移动.运行项目时没有任何反应.这是我的代码:
import android.app.Activity; import android.os.*; import android.view.animation.AccelerateInterpolator; import android.view.animation.TranslateAnimation; import android.widget.ImageView; public class MainActivity extends Activity { ImageView a; TranslateAnimation pengesat; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); a = (ImageView) findViewById(R.id.imageView3); pengesat = new TranslateAnimation( 0.0f, 1.0f, 0.0f, 0.0f ); pengesat.setDuration(5000); pengesat.setRepeatCount(1); pengesat.setInterpolator(new AccelerateInterpolator()); Thread myThread= new Thread(new Runnable(){ @Override public void run() { a.post(new Runnable() { @Override public void run() { a.startAnimation(pengesat); } }); } }); myThread.start(); } }
这是我的xml代码:
我究竟做错了什么?