0

I have a SimpleDraweeView which is inside a Recycler.

Recycler:

<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

SimpleDraweeView:

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

I tried a lot of ratio and scaleType but I can't seem to get the one that will display the full height(only 90% is displayed). The width is fine, but I can't seem to get the height properly. Which is the right combination to get a proper aspect ? (facebook like)

Bogdan Daniel
  • 2,689
  • 11
  • 43
  • 76

2 Answers2

5

I didn't really understand what kind of scale type you are looking for, but it is definitely going to be configured by Fresco's lib with one of the following properties:

  fresco:actualImageScaleType="focusCrop|centerCrop|..."
  fresco:placeholderImageScaleType="fitCenter"

Say you have some imageView of fixed height and 100% width:

  <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/feedImage"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        fresco:actualImageScaleType="centerInside" />
Iliiaz Akhmedov
  • 867
  • 7
  • 17
  • I just want to see the whole image. Like how it is displayed in the gallery or on a website. – Bogdan Daniel Nov 13 '15 at 20:09
  • No matter which I use I can see only 85% of the height of the image – Bogdan Daniel Nov 13 '15 at 20:12
  • I would usually use centerCrop, thus you will fill the imageView, but if you want it to fit center (all parts are visible and nothing is cropped), then there will be margins, since you imageView is probably of a fixed height and width – Iliiaz Akhmedov Nov 13 '15 at 21:14
  • How can I achieve a facebook look ? I mean if I post a picture there nothing gets cropped. What are their image properties ? – Bogdan Daniel Nov 13 '15 at 21:16
  • I get it now. Thank you, but that looks so bad for vertical images. Is there another approach ? – Bogdan Daniel Nov 13 '15 at 21:25
  • What exactly do you want to show? Think if there are long images in height, and big in width. You should understand how you want to handle this, then write the code. I usually do centerCrop and then images are clickabel to view them expanded – Iliiaz Akhmedov Nov 13 '15 at 21:28
  • I tried using centerCrop with the height set on "wrap_content" and I get only a line instead of the image. I have to use the aspectRatio I think to make it work – Bogdan Daniel Nov 13 '15 at 21:29
  • You can definitely use that or as an option you can have the height fixed. – Iliiaz Akhmedov Nov 13 '15 at 21:31
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/95086/discussion-between-iliiaz-akhmedov-and-bogdan-daniel). – Iliiaz Akhmedov Nov 13 '15 at 21:31
2

My assumption is you have a margin associated with the parent view. Link you XML file completely please, but most likely there is a RelativeLayout with a margin set.

Another thing, I see this android:layout_height="wrap_content" in the SimpleDraweeView. The width will match parent and the height is set to wrap_content so it isn't going to expand the height to be 100% without this. That is why there is a 90% fill of the image. Change to the following:

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

Other than that I need to see the XML to determine if there is something else causing this!

Lucas Crawford
  • 3,078
  • 2
  • 14
  • 25
  • 1
    I tried to use match_parent for both arguments, but for some reason the image won't display just a line. I posted about it on git and they said that because my Image is in a Recycler it doesn't have tha parameters for match_parent . – Bogdan Daniel Nov 13 '15 at 21:39