android.support.v7.widget.GridLayoutManager.scrollToPosition()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中android.support.v7.widget.GridLayoutManager.scrollToPosition()方法的一些代码示例,展示了GridLayoutManager.scrollToPosition()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridLayoutManager.scrollToPosition()方法的具体详情如下:
包路径:android.support.v7.widget.GridLayoutManager
类名称:GridLayoutManager
方法名:scrollToPosition

GridLayoutManager.scrollToPosition介绍

暂无

代码示例

代码示例来源:origin: architjn/MaterialIconPackTemplate

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.icon_fragment, container, false);
  Display display = getActivity().getWindowManager().getDefaultDisplay();
  Point size = new Point();
  display.getSize(size);
  int numOfRows = (int) (size.x / getResources().getDimension(R.dimen.size_of_grid_item));
  RecyclerView gridview = (RecyclerView) view.findViewById(R.id.icons_rv);
  GridLayoutManager layoutManager = new GridLayoutManager(view.getContext(), numOfRows);
  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  layoutManager.scrollToPosition(0);
  gridview.setLayoutManager(layoutManager);
  gridview.setHasFixedSize(true);
  gridview.addItemDecoration(new SpacesItemDecoration(10, 5));
  gridview.setAdapter(new IconsAdapter(view.getContext(),
      getArguments().getInt("iconsArrayId", 0)));
  return view;
}

代码示例来源:origin: YancyYe/GalleryPick

@Override
  public void onClick(FolderInfo folderInfo) {
    if (folderInfo == null) {
      getSupportLoaderManager().restartLoader(LOADER_ALL, null, mLoaderCallback);
      tvGalleryFolder.setText(R.string.gallery_all_folder);
    } else {
      photoInfoList.clear();
      photoInfoList.addAll(folderInfo.photoInfoList);
      photoAdapter.notifyDataSetChanged();
      tvGalleryFolder.setText(folderInfo.name);
    }
    folderListPopupWindow.dismiss();
    gridLayoutManager.scrollToPosition(0);
  }
});

代码示例来源:origin: architjn/MaterialIconPackTemplate

GridLayoutManager layoutManager = new GridLayoutManager(context, 2);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
layoutManager.scrollToPosition(0);
gridview.setLayoutManager(layoutManager);
gridview.setHasFixedSize(true);

相关文章