2016-05-23 57 views
0

我有一個從相機拍攝的圖像作爲「file:///storage/emulated/0/Pictures/Colony_Quantifier/IMG_20160523_204353.jpg」。在ImageView中顯示Uri Android

雖然我試圖在ImageView中顯示該圖像,但無論在互聯網中建議哪種選項,我都無法做到這一點。

Uri uri = Uri.parse("file:///storage/emulated/0/Pictures/Colony_Quantifier/IMG_20160523_204353.jpg"); 
imgCaptured.setImageURI(uri); 

回答

0

1-你創建一個Bitmap出URI

2-創建BitmapDrawable的傳入位圖

3-您添加BitmapDrawable到一個窗口的新實例(setBackgroundDrawable) ,視圖(setBackgroundDrawable)]或ImageView的(setImageDrawable)

1

嘗試使用:

ImageView.setImageURI(Uri.fromFile(new File("/sdcard/cats.jpg"))); 

或者:

ImageView.setImageURI(Uri.parse(new File("/sdcard/cats.jpg").toString())); 
0

您可以使用畢加索:

包括此行的模塊級的build.gradle依賴關係:

compile 'com.squareup.picasso:picasso:2.5.2' 

然後用它作爲:

Picasso.with(yourContext).load(uri).into(yourImageView);