簡體   English   中英

如何從 sdcard 加載圖像並使用它們將背景更改為 xml 布局文件?

[英]How can I load an image from sdcard and use them to change the background to xml layout files?

正如我在標題中所說,我在 xml 文件中有幾個屏幕,我在這個應用程序中使用它們:

Android 主屏幕

我需要在第一個活動中更新幾個文件。 如何從 SD 卡中讀取數據並將它們作為背景?

謝謝

對了 找到答案了! 我正在使用線性布局

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM