我正在構建一個Android Things“信息亭”風格的應用程序,我希望圖像像壁紙一樣顯示在背景中。我使用Unsplash源來獲取隨機圖像,但源URL(https://source.unsplash.com/1080x1920/?long-exposure)總是重定向到圖像URL,所以我不能使用這個:InputStream is = (InputStream) new URL("https://source.unsplash.com/1080x1920/?long-exposure").getContent();Drawable d = Drawable.createFromStream(is, "");niceWallpaper.setImageDrawable(d);有沒有辦法做到這一點?
2 回答

浮云間
TA貢獻1829條經驗 獲得超4個贊
使用可以解決您的問題。Picasso
String yourUrl = "https://source.unsplash.com/1080x1920/?long-exposure"; Picasso.with(MyApplication.getAppContext()).load(yourUrl).placeholder(defaultImage).memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).into(YourImageView);
添加回答
舉報
0/150
提交
取消