I'm making horizontal RecyclerView with photos in it, and I have faced up with wrap_parent problem. If I put in my View width = wrap_content
, it is screenWidth width, although image consumes very small space. If I change wrap_content
to some value it works perfectly.RecyclerView is 75dp height and match_parent
.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="75dp"
android:layout_height="wrap_content"
android:clickable="true"
android:foreground="@drawable/card_foreground">
<ImageView
android:id="@+id/bitmap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/image" />
</LinearLayout>
Dark blue is screen and light blue is photos. Problem is I have case 1 when I set view to wrap_content
.
SOLUTION:
I have solved this problem recently, there is some bug or something simmilar, when you try to have on scaled ImageView wrap_parent. It doesn't work very well.
To solve this, I have resized every photo to final size before put it in RecyclerView. In adition, I have some small space between ImageView again, and I have solved by adding padding=0
and margin=0
to childern of RecyclerView.