1

I am using RecyclerView with StaggeredGridLayoutManager in vertical orientation. Item of the RecyclerView contains only one view - ImageView. I would like the ImageView height to scale to match RecyclerView's column width and keep aspect ratio of photo that it contains. Currently parameters of this image view are: android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="centerCrop" but the height of the item in RecyclerView matches original height of the photo and the photo is just centered. How is it possible to achieve that?

Michał
  • 655
  • 6
  • 19

1 Answers1

6

Add this attribute to your ImageView:

    android:adjustViewBounds="true"

Image View | Android Developers

kris larson
  • 30,387
  • 5
  • 62
  • 74