壁画不显示图像

时间:2016-06-22 15:27:59

标签: android fresco

我正在尝试使用Fresco在RecyclerView中显示图片。我的文件系统中有图像,我希望通过SimpleDraweeView格式的图像位置在String中显示它。但在这个视图中我有空图像。日志不会显示任何错误。谁能帮我?这是我的代码,我正在尝试设置图像:

    imageView.setVisibility(View.VISIBLE);
    if (new File(imageData.getLocation()).exists()){
        Uri fileLocationUri = Uri.parse("file:/" + imageData.getLocation());
        ImageRequest request = ImageRequest.fromUri(fileLocationUri);
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setImageRequest(request)
                .setOldController(imageView.getController())
                .setAutoPlayAnimations(true)
                .build();
        imageView.setController(controller);
    }

图像位置是一个以/开头的字符串,因此Uri解析器返回正确的结果。 XML文件:

<com.facebook.drawee.view.SimpleDraweeView
        a:id = "@+id/outgoing_photo_view"
        a:layout_width="300dp"
        a:layout_height="300dp"
        a:adjustViewBounds="true"
        a:visibility="gone"
        fresco:actualImageScaleType="focusCrop"
        fresco:placeholderImageScaleType="fitCenter"
        fresco:failureImageScaleType="centerInside"
        fresco:retryImageScaleType="centerCrop"
        fresco:roundAsCircle="false"
        fresco:roundedCornerRadius="1dp"
        fresco:roundTopLeft="true"
        fresco:roundTopRight="false"
        fresco:roundBottomLeft="false"
        fresco:roundBottomRight="true"
        fresco:roundingBorderWidth="2dp"/>

1 个答案:

答案 0 :(得分:1)

我猜你的文件URI无效。

它应该适用于这样的事情:

File file = ... // your file
Uri uri = Uri.fromFile(file); // to get a valid file:// URI
DraweeController controller = Fresco.newDraweeControllerBuilder()
        .setUri(uri)
        .build();
相关问题