2017-08-26 34 views
0

首先我搜索了很多,我的情況沒有找到解決辦法,我需要轉換的IMAGEURL來繪製,我試圖儘可能:如何將imageurl轉換爲drawable?所有的

File imageFile = DiskCacheUtils.findInCache(c.profilePhoto, com.nostra13.universalimageloader.core.ImageLoader.getInstance().getDiscCache()); 

      String file_target = "file://" + imageFile.getPath(); 


      BitmapDrawable bitDraw = (BitmapDrawable) BitmapDrawable.createFromPath(file_target); 
      if (profilePhotos.size() == 4) break; 
      BitmapDrawable drawable = bitDraw; //getResources().getDrawable(c.profilePhoto); 
      drawable.setBounds(0, 0, width, height); 
      profilePhotos.add(drawable); 

此外,我試圖加載圖像轉換成位圖通過滑翔,但沒有奏效。

我怎麼能做到這一點?

在此先感謝。

+0

您試過這些鏈接? 1. https://stackoverflow.com/a/45073477/4116560 2. https://stackoverflow.com/a/45073604/4116560 – sam

+0

'file_target'不是路徑。 'imageFile.getPath()'是一個路徑。 'createFromPath()',基於它的名字,似乎期望一條路徑,並且你沒有提供路徑。除此之外,請隨時在實際的計算機編程術語中解釋您在代碼段中遇到的問題,以及關於Glide的「但無效」的含義。 – CommonsWare

+0

你嘗試過'Drawable#createFromStream()'嗎? – pskink

回答

2

第一轉換URL爲位圖,並通過位圖到這些功能

可繪製d =新BitmapDrawable(context.getResources(),位圖); return d;

+0

感謝您的回答,我會嘗試。 –

+0

您的歡迎兄弟 –