簡體   English   中英

壁畫不顯示圖像

[英]Fresco doesn't show image

我正在嘗試使用壁畫在RecyclerView顯示圖像。 我的文件系統中有圖像,我想按圖像位置以String格式在SimpleDraweeView顯示它。 但是在這種觀點下,我的形象是空的。 日志未顯示任何錯誤。 誰能幫我? 這是我要設置圖像的代碼:

    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"/>

我猜您的文件URI無效。

它應該可以像這樣工作:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM