ui更新以移动背景

时间:2014-12-01 19:26:46

标签: java android

我可以执行以下操作来更新UI。我实际上想要移动背景图像或像动画一样的位图。如果没有请帮我纠正。我是Android的新手。

float x=0;
float y=0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final ImageView img = (ImageView) findViewById(R.id.img_animation);

    new Thread(){
        public void run(){
            runOnUiThread(new Runnable(){
                public void run() {

                    for(;x<=200;)
                    {
                        x++;
                        img.setX(x);


                        try
                        {
                            sleep(1000);

                        }catch(Exception e)
                        {
                            System.out.println("Exception: "+e);
                        }
                    }
                }
            });
        }

}.start();

}

0 个答案:

没有答案