动态设置线性布局的背景 [英] Set Linear layout background dynamically

查看:152
本文介绍了动态设置线性布局的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过以下方式动态地设置线性布局的背景:

I wanted to set Linear Layout background dynamically in the following way:

  1. 通过XML解析获取从网页URL的图像,然后将该图像保存到SD卡上。

  1. Fetch image from web url through XML parsing and then store that image into sd card.

现在保存到SD卡上的图像。

Now the image saved into sd card.

设置图像作为一个线性布局的背景中的应用程序。

Set that image as a linear layout background in the app.

现在我坚持在第三步。任何人都可以帮忙吗?

Now I am stuck in the third step. Can anyone help?

推荐答案

使用这样的:

Bitmap bmImg = BitmapFactory.decodeStream(is);
BitmapDrawable background = new BitmapDrawable(bmImg);
linearLayout.setBackgroundDrawable(background);

另外检查:如何将位图转换为可绘在Android的?

这篇关于动态设置线性布局的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆