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

浮云間
TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超4個(gè)贊
使用可以解決您的問題。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);
添加回答
舉報(bào)
0/150
提交
取消