I implement a horizontal RecyclerViewone that snaps items to the center after scrolling, such as the Google play App horizontal lists. This is an overview.
My code is below:
MainMenuAdapter mainMenuAdapter = new MainMenuAdapter(this, mDataset);
final LinearLayoutManager layoutManagaer = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
RecyclerView mainMenu = (RecyclerView) findViewById(R.id.main_menu);
mainMenu.setLayoutManager(layoutManagaer);
mainMenu.setAdapter(mainMenuAdapter);
final SnapHelper snapHelper = new LinearSnapHelper();
snapHelper.attachToRecyclerView(mainMenu);
snapHelper.attachToRecyclerView(mainMenu);
How can I get the center position (position) after RecyclerView, tying it to the center? Is there really no listener opportunity for this? Also, when I need to touch an element, I want to snap it to the center. How can i do this?
source
share