【问题标题】:How can I load an image from sdcard and use them to change the background to xml layout files?如何从 sdcard 加载图像并使用它们将背景更改为 xml 布局文件?
【发布时间】:2011-04-30 15:32:01
【问题描述】:

正如我在标题中所说,我在 xml 文件中有几个屏幕,我在这个应用程序中使用它们:

Android Homescreen

我需要在第一个活动中更新几个文件。如何从 SD 卡中读取数据并将其作为背景?

谢谢

【问题讨论】:

    标签: android xml background image


    【解决方案1】:

    正确找到了答案!我正在使用线性布局

       // Get External Storage Directory
        String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();
        LinearLayout li=(LinearLayout)findViewById(R.id.layoutid);
        li.setBackgroundDrawable(Drawable.createFromPath(newFile(sdcard,"/s1bg.jpg").getAbsolutePath()));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-18
      • 2013-04-06
      • 1970-01-01
      • 2020-10-29
      • 1970-01-01
      • 2017-07-01
      • 2021-02-15
      • 1970-01-01
      相关资源
      最近更新 更多