Shikha Ratra Shikha Ratra - 1 year ago 113
Android Question

How to center the Clicked position in the Recyclerview

I want to center the clicked position in the

. I am able to scroll the
to certain position but i want to middle that position in the screen.
I used this method to scroll to that position.


Answer Source

if you use linearlayoutManager, you can use this code,

linearLayoutManager.scrollToPositionWithOffset(2, 20);

(linearLayoutManager.void scrollToPositionWithOffset (int position, 
            int offset))

Setting the offset to 0 should align with the top

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download