1.
setContentView(R.layout.main);
this.getWindow().setBackgroundDrawable(Drawable.createFromPath(Path));
以上语句如果AndroidManifest.xml 有语句
android:background="" 则无效,要等程序跑起一段时间后才有效,例如按某个button后。
2. 点击后改变button背景
a : mButton1.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v){
/*
Toast toast = Toast.makeText(IDOdestopActivity.this,"you press button " +
mButton1.getText() ,Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP, 0, 100);
toast.show();
*/
v.setBackgroundDrawable(Drawable.createFromPath("/data/a/sunset.png"));
}
});
b: 可以在xml里修改:
http://www.cnblogs.com/nicklezhang/archive/2011/01/22/1941911.html