Nathan
Nathan

Reputation: 138

RecyclerView items with big empty space v25.2.0

I've read many posts here about RecycerView change after 23.2.0 however I'm still facing the huge blank space inside my recycler view. I created a small project on GitHub to demonstrate the issue: https://github.com/nathan-ca/TrialRecycler

Here is the screenshot:

enter image description here

I used a line border to draw around the item and its size is almost twice of the screen height. In the list_item.xml, if I change the layout_height to a fixed value, say '100dp', the recycler view will show item correctly. If I change to match_parent, the height is the same as the window. When I use wrap_content, the height is twice the window! All online posts say it should work well if I use 'wrap_content'. Desperately don't know where the problem is.

Upvotes: 1

Views: 123

Answers (2)

Nathan
Nathan

Reputation: 138

Alright, after a good night sleep and more stackoverflow/google search, I found the issue: I should call

imageView.setAdjustViewBounds(true);  

I committed the fix and the layout looks well.

Upvotes: 0

RoShan Shan
RoShan Shan

Reputation: 2954

I see your code and realize that you don't fix layout_height of ImageView, try to fix it to 60dp

<ImageView
    android:id="@+id/item_image"
    android:layout_width="60dp"
    android:layout_height="wrap_content"
    />

Upvotes: 1

Related Questions