0

I am trying to create a layout where the contents in the recyclerview will start centered in the screen. The idea is that you would be able to scroll through it and they will shift over to the left side (image 2), with the center most item being the selected item. I'm not quite sure how to begin to make this happpen.

Thanks in advance.

start state

scrolling state

Nick
  • 925
  • 1
  • 8
  • 13
  • imo, we can calculate the screen width and setPadding for RecyclerView and clipToPadding = false. – Norutan Dec 07 '16 at 07:17
  • you can add empty view with the width of the half screen to it's start for example – Vladyslav Matviienko Dec 07 '16 at 07:20
  • [Check this answer](http://stackoverflow.com/questions/34586637/get-center-visible-item-of-recycleview-when-scrolling/34647005#34647005) – Vygintas B Dec 07 '16 at 07:21
  • Thanks @tanTran! How do I detect the center item? – Nick Dec 07 '16 at 07:38
  • 1
    @Nick paddingStart = (screenWidth - itemWidth) / 2 [ - itemPadding] – Norutan Dec 07 '16 at 08:28
  • @TanTran, say item 3 is in the center, how would I know that that is the center item and that the center item changed? – Nick Dec 07 '16 at 08:45
  • 1
    @Nick try to get the item position in screen (x and y, not the position in recyclerView) and choose which is the best item – Norutan Dec 07 '16 at 09:06
  • @TanTran, so close! But when you set the padding, the items don't scroll all the way to the end. I need to be able to set the last/first items to be in the center of the screen. – Nick Dec 07 '16 at 17:47

0 Answers0