设置背景图片的相对布局?布局、背景图片

2023-09-06 02:24:35 作者:蜡笔小丸子

我已经下载的图像在运行时。现在我想将它设置为背景的相对布局如何呢?是否有可能。

I have downloaded image at run time. Now I want to set it as a background for relative layout how to it? Does it possible.

推荐答案

退房的 setBackgroundDrawable ,或者在绘制对象类createFromPath 。

   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);