设置背景图片的相对布局? [英] Setting background image for relative layout?
本文介绍了设置背景图片的相对布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经下载的图像在运行时。现在我想将它设置为背景的相对布局如何呢?是否有可能。
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.
推荐答案
退房的<一个href="http://developer.android.com/reference/android/view/View.html#setBackgroundDrawable(android.graphics.drawable.Drawable)"相对=nofollow> setBackgroundDrawable ,或者<一href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html#createFromPath(java.lang.String)"相对=nofollow>在绘制对象类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);
这篇关于设置背景图片的相对布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文