就是让layout的背景为动画,求问一下这个可以实现不
不能,这个需要背景图,和前面一张用算法操作动态的图才可以
貌似可以,用帧动画。
package com.test.zhang.test;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.widget.LinearLayout;
import android.widget.SlidingDrawer;
public class TestActivity extends Activity implements Runnable{
LinearLayout ll;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ll=(LinearLayout) findViewById(R.id.test);
Thread thread=new Thread(this);
thread.start();
}
@Override
public void run() {
int i=1;
while (true) {
drawable=null;
int test=getResources().getIdentifier("gallery_photo_"+i, "drawable",
this.getPackageName());
System.out.println("test:"+test);
drawable=getResources().getDrawable(test);
i++;
if(i>8){
i=1;
}
handler.sendEmptyMessage(0);
try {
Thread.sleep(200);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Drawable drawable=null;
Handler handler=new Handler(){
public void handleMessage(android.os.Message msg) {
if(drawable!=null){
ll.setBackgroundDrawable(drawable);
}};};}