当前位置: 首页>>代码示例>>Java>>正文


Java PagerSnapHelper.attachToRecyclerView方法代码示例

本文整理汇总了Java中android.support.v7.widget.PagerSnapHelper.attachToRecyclerView方法的典型用法代码示例。如果您正苦于以下问题:Java PagerSnapHelper.attachToRecyclerView方法的具体用法?Java PagerSnapHelper.attachToRecyclerView怎么用?Java PagerSnapHelper.attachToRecyclerView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.PagerSnapHelper的用法示例。


在下文中一共展示了PagerSnapHelper.attachToRecyclerView方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import android.support.v7.widget.PagerSnapHelper; //导入方法依赖的package包/类
@Override
protected View onCreateView() {
    View root = LayoutInflater.from(getContext()).inflate(R.layout.fragment_pagerlayoutmanager, null);
    ButterKnife.bind(this, root);

    mQDItemDescription = QDDataManager.getInstance().getDescription(this.getClass());
    initTopBar();

    mRecyclerView = new RecyclerView(getContext());
    mPagerLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
    mRecyclerView.setLayoutManager(mPagerLayoutManager);
    mRecyclerViewAdapter = new QDRecyclerViewAdapter();
    mRecyclerViewAdapter.setItemCount(10);
    mRecyclerView.setAdapter(mRecyclerViewAdapter);
    mPagerWrap.addView(mRecyclerView);
    // PagerSnapHelper每次只能滚动一个item;用LinearSnapHelper则可以一次滚动多个,并最终保证定位
    // mSnapHelper = new LinearSnapHelper();
    mSnapHelper = new PagerSnapHelper();
    mSnapHelper.attachToRecyclerView(mRecyclerView);
    return root;
}
 
开发者ID:coopese,项目名称:qmui,代码行数:22,代码来源:QDSnapHelperFragment.java

示例2: onCreateRecyclerView

import android.support.v7.widget.PagerSnapHelper; //导入方法依赖的package包/类
@Override
public void onCreateRecyclerView(Bundle savedInstanceState) {
  int backgroundColor = 0xFF665F30;
  Context context = this;
  recyclerView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
  recyclerView.setBackgroundColor(backgroundColor);

  SimpleViewAdapter adapter = new SimpleViewAdapter(5, R.layout.item_view_pager_page);

  recyclerView.setAdapter(adapter);
  recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));

  // add pager behavior
  PagerSnapHelper snapHelper = new PagerSnapHelper();
  snapHelper.attachToRecyclerView(recyclerView);

  // pager indicator
  recyclerView.addItemDecoration(new LinePagerIndicatorDecoration());

}
 
开发者ID:bleeding182,项目名称:recyclerviewItemDecorations,代码行数:21,代码来源:ViewPagerActivity.java

示例3: initSnapHelper

import android.support.v7.widget.PagerSnapHelper; //导入方法依赖的package包/类
/**
 * 初始化SnapHelper
 *
 * @param helper
 */
public void initSnapHelper(int helper) {
    switch (helper) {
        case GalleryRecyclerView.LinearySnapHelper:
            mLinearySnapHelper = new LinearSnapHelper();
            mLinearySnapHelper.attachToRecyclerView(mGalleryRecyclerView);
            break;
        case GalleryRecyclerView.PagerSnapHelper:
            mPagerSnapHelper = new PagerSnapHelper();
            mPagerSnapHelper.attachToRecyclerView(mGalleryRecyclerView);
            break;
    }
}
 
开发者ID:ryanlijianchang,项目名称:Recyclerview-Gallery,代码行数:18,代码来源:ScrollManager.java


注:本文中的android.support.v7.widget.PagerSnapHelper.attachToRecyclerView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。