Reputation: 1673
I have RecyclerView
with GridLayoutManger
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.movie_posters_recycler_view);
recyclerView.setHasFixedSize(true);
mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
Each RecyclerView's item represented by following layout
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/movie_item_poster_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true" />
</FrameLayout>
Currently I have such result
I want to do this
Upvotes: 4
Views: 2654
Reputation: 587
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/movie_thumbnail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:adjustViewBounds="true"/>
</FrameLayout>
This should work
Upvotes: 4
Reputation: 286
Using android:scaleType="fitXY"
in ImageView
attributes should stretch the image inside the ImageView
.
Upvotes: 0
Reputation: 1752
Take a look at this answer: https://stackoverflow.com/a/26575808/4729523.
You just need to keep the image's aspect ratio (3/4 or 9/16).
Upvotes: 0
Reputation: 14825
Replace your image view with this one
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/movie_item_poster_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true" />
Upvotes: 0