devunwired / recyclerview-playground

Examples of RecyclerView use and custom LayoutManager implementations
MIT License
1.24k stars 269 forks source link

Padding doubled in FixedTwoWayList on first layout #25

Closed stephansmolek closed 8 years ago

stephansmolek commented 8 years ago

Hi Dave, there is a problem when adding a padding to the RecyclerView and with the FixedGridLayoutManager.

Steps to reproduce: Add a padding to the Recyclerview in fragment_recycler.xml eg.:

android:padding="30dp"
android:clipToPadding="false"

Start the app, select "Fixed Two-Way List" and then "Large Grid" The padding is now double the size is should be. When you start to scroll it jumps back to the correct padding.

I was able to fix it by changing line 263 in FixedGridLayoutManager.java to: fillGrid(DIRECTION_NONE, 0, 0, recycler, state, removedCache); but I am not sure about any other effects this might have.

Best regards, Stephan

stephansmolek commented 8 years ago

Okay, this is not a fix, it has the effect of scrolling the RecyclerView when the first layout is done at another position (eg. coming back from another activity).

devunwired commented 8 years ago

Thanks for reporting this, I've pushed a fix. The padding should have only been taken into account during an initial layout phase (when the positions would otherwise be zero), and not on every fill.