linearlayoutmanager

Horizontally center first item of RecyclerView

旧街凉风 提交于 2019-11-30 09:58:27
I want to use a RecyclerView to emulate the behavior of a MultiViewPager , in particular I'd like to have the selected item at the center of the screen, including the first and the last element . As you can see in this image, the first item is centered and this would be my expected result. What I did was to setup a RecyclerView with an horizontal LinearLayoutManager and a LinearSnapHelper . The problem with this solution is that the first and the last item will never be horizontally centered as selection. Should I switch my code so that it uses a MultiViewPager or is it possible to achieve a

RecyclerView smoothScroll to position in the center. android

时光总嘲笑我的痴心妄想 提交于 2019-11-28 18:43:00
I am using horizontal layout manager for my RecyclerView . I need make RecyclerView in next way: when click on some item - make smoothScrool to that position and put that item in the center of RecyclerView (if it possible, for example 10 item from 20). So, I have no problem with smoothScrollToPosition() , but how to put item than in the center of RecyclerView ??? Thanks! user3680200 Yes it's possible. By implementing RecyclerView.SmoothScroller 's method onTargetFound(View, State, Action) . /** * Called when the target position is laid out. This is the last callback SmoothScroller * will

RecyclerView smoothScroll to position in the center. android

泪湿孤枕 提交于 2019-11-27 01:06:10
问题 I am using horizontal layout manager for my RecyclerView . I need make RecyclerView in next way: when click on some item - make smoothScrool to that position and put that item in the center of RecyclerView (if it possible, for example 10 item from 20). So, I have no problem with smoothScrollToPosition() , but how to put item than in the center of RecyclerView ??? Thanks! 回答1: Yes it's possible. By implementing RecyclerView.SmoothScroller 's method onTargetFound(View, State, Action) . /** *