簡體   English   中英

如何從assets文件夾中的圖像創建drawable?

[英]How to create a drawable from an image in assets folder?

此代碼始終返回null

String path = "file:///android_asset/image.png";
Drawable d = null;
try {
     d = Drawable.createFromStream(ContextHolder.getActivity().getAssets().open(path), null);
} catch(Exception e) {

}
Drawable d = Drawable.createFromStream(getAssets().open("image.png"), null);

路徑錯了

String path = "image.png";

暫無
暫無

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

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