Reputation: 655
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?
Upvotes: 1
Views: 1319
Reputation: 30985
Add this attribute to your ImageView
:
android:adjustViewBounds="true"
Image View | Android Developers
Upvotes: 7