2012-07-29 96 views
0

我正在制作一个由两个活动组成的应用程序。第一项活动是只有一个按钮的首页。当这个按钮被击中时,下一个活动开始。我的可绘制文件由10个图像组成。第二个活动选择这十个随机图像,并在屏幕上显示图像。我的问题是:有没有一种方法可以将所显示的图像制作成手机bakcgroundimage。我不是指应用程序背景图像,而是手机本身的背景。最好在java中而不是在xml中。 谢谢通过应用程序在手机上创建背景

回答

1
//Put this code into onCreate method 
//Create array of your images as drawable object and choose random for background.  
LinearLayout ll = new LinearLayout(this); 
LayoutParams lparams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); 
ll.setLayoutParams(lparams); 
ll.setBackgroundDrawable(getResources().getDrawable(R.drawable.icon)); 

setContentView(ll); 
+0

以上将有助于解决问题。 – 2012-07-30 11:11:00