我正在实现一个水平RecyclerView
,在滚动后将项目捕捉到中心,例如 Google play App 水平列表。这是一篇评论。
我的代码如下:
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);
RecyclerView
将中心项目(位置)卡到中心后如何获取中心项目(位置) ?没有任何监听器实现吗?此外,当触摸项目视图时,我想将其对齐到中心。我怎样才能做到这一点?