如何通过Android中的Url设置布局的背景图像?

时间:2013-03-23 10:48:53

标签: android android-layout android-imageview

在我的应用程序中,通过JSON从web url设置布局背景。但在图像视图中,我设置如下

try {
                  ImageView i = (ImageView)findViewById(R.id.animation);
                  Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL("http://alpharithm.in/manager/test/img/files/products/mushroom-soup.jpg").getContent());
                  i.setImageBitmap(bitmap); 
                } catch (MalformedURLException e) {
                  e.printStackTrace();
                } catch (IOException e) {
                  e.printStackTrace();
                }

不要设置为背景。如何为布局设置背景?

1 个答案:

答案 0 :(得分:1)

你可以从中获得参考。

Set Linear Layout Background

希望这会对你有所帮助。