setImageViewUri 不显示图片,但显示 imageview 的背景

setImageViewUri doesn't show picture but show background of imageview

File file = new File("/storage/emulated/0/BabyCareData/photo/20160229_161413.jpg");
if (file.exists()) {
    views.setImageViewUri(R.id.imageAvatar, Uri.parse(file.getPath()));             
} 

我已经检查了路径和uri,是正确的。setImageViewUri不显示图片但显示白屏(背景是白色的)。

试试这个:

File file = new File(/storage/emulated/0/BabyCareData/photo/20160229_161413.jpg);

if(file.exists())
{

    Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
    setBitmap(views,R.id.imageAvatar,myBitmap);

}

    private void setBitmap(RemoteViews views, int resId, Bitmap bitmap){
        Bitmap proxy = Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(), Bitmap.Config.ARGB_8888);
        Canvas c = new Canvas(proxy);
        c.drawBitmap(bitmap, new Matrix(), null);
        views.setImageViewBitmap(resId, proxy);
    }

试试这个:

File file = new File("/storage/emulated/0/BabyCareData/photo/20160229_161413.jpg");
        if (file.exists()) {
            Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
            views.setImageViewBitmap(R.id.imageAvatar, bitmap);              
        }