我在运行时下载了一张图片。现在我想将它设置为 RelativeLayout
的背景。可能吗?
最佳答案
查看 setBackgroundDrawable ,或者可能是 createFromPath在 Drawable 类中。
RelativeLayout rLayout = (RelativeLayout) findViewById (R.id.rLayout);
Resources res = getResources(); //resource handle
Drawable drawable = res.getDrawable(R.drawable.newImage); //new Image that was added to the res folder
rLayout.setBackground(drawable);
关于Android:为RelativeLayout设置背景图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4906422/