壁画图像的宽度和高度 - match_parent不显示 [英] Fresco Image with both width and height - match_parent doesn't display

查看:492
本文介绍了壁画图像的宽度和高度 - match_parent不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有它加载使用壁画库图像的应用程序。我有2个问题。
1.如果我使用这样的壁画图像

 < com.facebook.drawee.view.SimpleDraweeView
        机器人:ID =@ + ID / feedImage
        机器人:layout_width =match_parent
        机器人:layout_height =match_parent
        />

它不会显示任何东西,但细线的颜色,其中的形象应该是。

但是,如果我做这样的事情。

 < com.facebook.drawee.view.SimpleDraweeView
        机器人:ID =@ + ID / feedImage
        机器人:layout_width =match_parent
        机器人:layout_height =WRAP_CONTENT
        壁画:viewAspectRatio =1.33
        机器人:scaleType =fitXY
        />

一切工作正常(但我没有看到完整的图像)。

我要实现同样的观点如Facebook(图片全宽度和高度)。

<醇开始=2>
  • 我在一个回收列表加载图像。这些图像加载到缓存中(我证实),但如果我一路走下来,然后备份我可以看到正在加载的图片(Facebook并没有这个问题,他们使用相同的库)。如果我真的滚动速度慢是没有问题的。近日笔者从凌空改变,(所以它不是回收)之前,我没有这个问题。我怎样才能解决这个问题?

  • 编辑:还有别的东西,我注意到的是,如果我禁用磁盘缓存,并终止该应用的文档说不会被删除缓存。我知道,如果我叫 ImagePipeline imagePipeline = Fresco.getImagePipeline();乌里URI; imagePipeline.evictFromMemoryCache(URI); 缓存将被删除,但不应该这样被自动


    解决方案

    因此​​,对于问题2我不能完全肯定我理解正确的问题,它不是在所有问题。图像很可能在内存缓存,但是存储在缓存中的图像仍然需要去$ C $光盘才可以在屏幕上显示,这可能是你说的那个加载问题。你只能通过快速滚动时看到这种情况的原因是因为您正在使用RecyclerAdapter正赶上滚动位置。(这是一个受过教育的猜测,绝不应这样假设是正确的)。当您移动缓慢,没有看到图像加载是因为适配器开始之前,它是在屏幕上加载下一个ViewHolder,但不是说点之前多。所以,当你快速地滚动,我相信它只是适配器发挥其OnBindViewHolder通话迎头赶上,而不是通过缓慢地移动它并不需要赶上来,并装载了你达到了recyclerview下一个项目之前的图像。

    当应用程序被后台运行,如内存缓存的磁盘缓存也不会被清除,所以如果需要的话,您将需要驱逐它。

    我不知道问题#1,但我会尽力找出原因,可能是。也许尝试设置scaletype到CropCenter或东西,看看是否能赶走你的线条。

    I have an app which loads an image using the fresco library. I have 2 problems. 1. If I use the fresco image like this

    <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/feedImage"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            />
    

    it won't display anything but a thin line of colors where the image should be.

    However if I do something like

    <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/feedImage"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            fresco:viewAspectRatio="1.33"
            android:scaleType="fitXY"
            />
    

    everything is working fine(but I don't see the full image).

    I want to achieve the same view as facebook(images full width and height).

    1. I load the images in a list in a recycler. The images are loaded into cache(I verified that) but if I go all the way down and then back up I can see the images being loaded(facebook doesn't have this problem and they use the same library). If I scroll really slow there is no problem. I recently changed from volley and I did not have this problem before(so it's not the recycler). How can I solve this ?

    Edit: And something else that I noticed is that if I disable the disk cache and kill the app the cache is not deleted as the documentation says. I know that if I call ImagePipeline imagePipeline = Fresco.getImagePipeline(); Uri uri; imagePipeline.evictFromMemoryCache(uri); the cache will be deleted, but shouldn't this be automatically ?

    解决方案

    So for problem #2 I am not entirely sure I understand the problem correctly it isnt a problem at all. The image may very well be in memory cache, however the image stored in cache still needs to be decoded before it can be displayed on screen, which is probably that loading issue you speak of. The reason you only see this when scrolling through quickly is because the RecyclerAdapter that you are using is catching up to the scroll position.(this is an educated guess, by no means should this be assumed to be correct). When you move slowly and dont see the image loading is because the Adapter starts to load the next ViewHolder before it is on screen, but not much before that point. SO when you scroll quickly I believe it is simply the Adapter playing catching up with its OnBindViewHolder call, as opposed to moving through slowly it doesnt need to play catch up and has the image loaded before you reach the next item in the recyclerview.

    The disk cache is not cleared when the app is backgrounded like memory cache, so if needed you will need to evict it.

    I am not sure about issue #1 but I will try to find out why that may be. Maybe try setting the scaletype to CropCenter or something and see if that rids you of the lines.

    这篇关于壁画图像的宽度和高度 - match_parent不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆