Java Code Examples for android.support.v7.widget.RecyclerView#setOverScrollMode()

The following examples show how to use android.support.v7.widget.RecyclerView#setOverScrollMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewHelper.java    From FABRevealMenu-master with Apache License 2.0 7 votes vote down vote up
public RecyclerView generateMenuView(boolean enableNestedScrolling) {
    //Create menu view
    RecyclerView mMenuView = new RecyclerView(mContext);
    mMenuView.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER);
    mMenuView.setBackgroundColor(Color.TRANSPARENT);
    mMenuView.setLayoutParams(matchParams);
    final int padding = dpToPx(mContext, 10);
    mMenuView.setPadding(padding, padding, padding, padding);
    mMenuView.setNestedScrollingEnabled(enableNestedScrolling);
    return mMenuView;
}
 
Example 2
Source File: PathLayoutManager.java    From PathLayoutManager with Apache License 2.0 6 votes vote down vote up
/**
     * 通过反射替换默认的Item动画 (解决在某些机型上的crash问题)
     */
    private void initItemAnimator() {
        try {
            Field field = RecyclerView.LayoutManager.class.getDeclaredField("mRecyclerView");
            field.setAccessible(true);
            RecyclerView recyclerView = (RecyclerView) field.get(this);
            if (recyclerView != null) {
                recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
                recyclerView.setHorizontalScrollBarEnabled(false);
                recyclerView.setVerticalScrollBarEnabled(false);
                if (recyclerView.getItemAnimator() != mItemAnimator) {
                    recyclerView.setItemAnimator(mItemAnimator);
                }
            }
//            recyclerView.setItemAnimator(null);
            mRecycler.setViewCacheSize(mCacheCount);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
Example 3
Source File: RecyclerViewSimpleFragment.java    From ScrollableLayout with Apache License 2.0 6 votes vote down vote up
public void initRecyclerView(View view) {
    recyclerView = (RecyclerView) view.findViewById(R.id.v_scroll);
    recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);

    LinearLayoutManager mLayoutMgr = new LinearLayoutManager(getContext());
    recyclerView.setLayoutManager(mLayoutMgr);

    recyclerAdapter = new RecyclerAdapter();
    recyclerView.setAdapter(recyclerAdapter);
    recyclerView.addOnScrollListener(mOnScrollListener);

    if (mLoadingFooter == null) {
        mLoadingFooter = new LoadingFooter(getContext());
        recyclerAdapter.setFooterView(mLoadingFooter);
    }

    getDataTask();
}
 
Example 4
Source File: ContentFragment.java    From VerticalViewPager with MIT License 5 votes vote down vote up
private void initRecyclerView(View view) {
    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.content_list);
    recyclerView.setOnTouchListener(new VerticalVPOnTouchListener((DummyViewPager) getArguments().getSerializable("viewpager")));//set the vertical scroll controller
    recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(new ContentAdapter(getPosition()));
}
 
Example 5
Source File: SmartRecycleView.java    From AutoRecycleView with Apache License 2.0 5 votes vote down vote up
private void initView() {
    mPullRereshLayout = new PullToRefreshLayout(mContext);
    addView(mPullRereshLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    mRecyclerView = new RecyclerView(mContext);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOverScrollMode(SCROLL_AXIS_NONE);
    mPullRereshLayout.addView(mRecyclerView,
            new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT));

    init();
}
 
Example 6
Source File: AboutAdapter.java    From wallpaperboard with Apache License 2.0 5 votes vote down vote up
HeaderViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    RecyclerView recyclerView = itemView.findViewById(R.id.recyclerview);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, true));
    recyclerView.setHasFixedSize(true);

    String[] urls = mContext.getResources().getStringArray(R.array.about_social_links);
    if (urls.length == 0) {
        recyclerView.setVisibility(View.GONE);

        subtitle.setPadding(
                subtitle.getPaddingLeft(),
                subtitle.getPaddingTop(),
                subtitle.getPaddingRight(),
                subtitle.getPaddingBottom() + mContext.getResources().getDimensionPixelSize(R.dimen.content_margin));
    } else {
        if (recyclerView.getLayoutParams() instanceof LinearLayout.LayoutParams) {
            LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) recyclerView.getLayoutParams();
            if (urls.length < 7) {
                params.width = LinearLayout.LayoutParams.WRAP_CONTENT;
                params.gravity = Gravity.CENTER_HORIZONTAL;
                recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
            }
        }
        recyclerView.setAdapter(new AboutSocialAdapter(mContext, urls));
    }

    subtitle.setHtml(mContext.getResources().getString(R.string.about_desc));

    CardView card = itemView.findViewById(R.id.card);
    if (!Preferences.get(mContext).isShadowEnabled()) {
        if (card != null) card.setCardElevation(0);

        profile.setShadowRadius(0f);
        profile.setShadowColor(Color.TRANSPARENT);
    }
}
 
Example 7
Source File: ItemOptionView.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
public ItemOptionView(@NonNull Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    this.DRAG_THRESHOLD = 20.0f;
    _paint = new Paint(1);
    _registeredDropTargetEntries = new HashMap<>();
    _tempArrayOfInt2 = new int[2];
    _dragLocation = new PointF();
    _dragLocationStart = new PointF();
    _dragLocationConverted = new PointF();
    _overlayIconScale = 1.0f;
    _overlayPopupAdapter = new FastItemAdapter<>();
    _previewLocation = new PointF();
    _slideInLeftAnimator = new SlideInLeftAnimator(new AccelerateDecelerateInterpolator());
    _slideInRightAnimator = new SlideInRightAnimator(new AccelerateDecelerateInterpolator());
    _paint.setFilterBitmap(true);
    _paint.setColor(Setup.appSettings().getDesktopFolderColor());
    _overlayView = new OverlayView();
    _overlayPopup = new RecyclerView(context);
    _overlayPopup.setVisibility(View.INVISIBLE);
    _overlayPopup.setAlpha(0);
    _overlayPopup.setOverScrollMode(2);
    _overlayPopup.setLayoutManager(new LinearLayoutManager(context, 1, false));
    _overlayPopup.setItemAnimator(_slideInLeftAnimator);
    _overlayPopup.setAdapter(_overlayPopupAdapter);
    addView(_overlayView, new LayoutParams(-1, -1));
    addView(_overlayPopup, new LayoutParams(-2, -2));
    setWillNotDraw(false);
}
 
Example 8
Source File: DesktopOptionView.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
private RecyclerView createRecyclerView(FastAdapter adapter, int gravity, int paddingHorizontal) {
    RecyclerView actionRecyclerView = new RecyclerView(getContext());
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
    actionRecyclerView.setClipToPadding(false);
    actionRecyclerView.setPadding(paddingHorizontal, 0, paddingHorizontal, 0);
    actionRecyclerView.setLayoutManager(linearLayoutManager);
    actionRecyclerView.setAdapter(adapter);
    actionRecyclerView.setOverScrollMode(OVER_SCROLL_ALWAYS);
    LayoutParams actionRecyclerViewLP = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    actionRecyclerViewLP.gravity = gravity;

    addView(actionRecyclerView, actionRecyclerViewLP);
    return actionRecyclerView;
}
 
Example 9
Source File: IndexStickyView.java    From IndexStickyView with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化数据列表视图
 * @param context
 */
private void initRecyclerView(Context context) {

    mLinearLayoutManager = new LinearLayoutManager(context);
    mRecyclerView = new RecyclerView(context);
    mRecyclerView.setVerticalScrollBarEnabled(false);
    mRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mRecyclerView.setLayoutManager(mLinearLayoutManager);
    mRecyclerView.addOnScrollListener(new RecyclerViewScrollListener());

    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    addView(mRecyclerView, layoutParams);
}
 
Example 10
Source File: IndexableLayout.java    From IndexableRecyclerView with Apache License 2.0 5 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    this.mContext = context;
    this.mExecutorService = Executors.newSingleThreadExecutor();
    PADDING_RIGHT_OVERLAY = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 80, getResources().getDisplayMetrics());

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IndexableRecyclerView);
        mBarTextColor = a.getColor(R.styleable.IndexableRecyclerView_indexBar_textColor, ContextCompat.getColor(context, R.color.default_indexBar_textColor));
        mBarTextSize = a.getDimension(R.styleable.IndexableRecyclerView_indexBar_textSize, getResources().getDimension(R.dimen.default_indexBar_textSize));
        mBarFocusTextColor = a.getColor(R.styleable.IndexableRecyclerView_indexBar_selectedTextColor, ContextCompat.getColor(context, R.color.default_indexBar_selectedTextColor));
        mBarTextSpace = a.getDimension(R.styleable.IndexableRecyclerView_indexBar_textSpace, getResources().getDimension(R.dimen.default_indexBar_textSpace));
        mBarBg = a.getDrawable(R.styleable.IndexableRecyclerView_indexBar_background);
        mBarWidth = a.getDimension(R.styleable.IndexableRecyclerView_indexBar_layout_width, getResources().getDimension(R.dimen.default_indexBar_layout_width));
        a.recycle();
    }

    if (mContext instanceof Activity) {
        ((Activity) mContext).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    }

    mRecy = new RecyclerView(context);
    mRecy.setVerticalScrollBarEnabled(false);
    mRecy.setOverScrollMode(View.OVER_SCROLL_NEVER);
    addView(mRecy, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    mIndexBar = new IndexBar(context);
    mIndexBar.init(mBarBg, mBarTextColor, mBarFocusTextColor, mBarTextSize, mBarTextSpace);
    LayoutParams params = new LayoutParams((int) mBarWidth, LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.END | Gravity.CENTER_VERTICAL;
    addView(mIndexBar, params);

    mRealAdapter = new RealAdapter();
    mRecy.setHasFixedSize(true);
    mRecy.setAdapter(mRealAdapter);

    initListener();
}
 
Example 11
Source File: RecyclerViewGridSimpleFragment.java    From ScrollableLayout with Apache License 2.0 5 votes vote down vote up
public void initRecyclerView(View view) {
    recyclerView = (RecyclerView) view.findViewById(R.id.v_scroll);
    recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);

    GridLayoutManager mLayoutMgr = new GridLayoutManager(getActivity(), 3);
    recyclerView.setLayoutManager(mLayoutMgr);

    PhotoAdapter recyclerAdapter = new PhotoAdapter();
    recyclerAdapter.setPhotos(createItemList());
    recyclerView.setAdapter(recyclerAdapter);
}
 
Example 12
Source File: ChatRoomMsgListPanel.java    From NIM_Android_UIKit with MIT License 5 votes vote down vote up
private void initListView() {
    // RecyclerView
    messageListView = (RecyclerView) rootView.findViewById(R.id.messageListView);
    messageListView.setLayoutManager(new LinearLayoutManager(container.activity));
    messageListView.requestDisallowInterceptTouchEvent(true);
    messageListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            if (newState != RecyclerView.SCROLL_STATE_IDLE) {
                container.proxy.shouldCollapseInputPanel();
            }
        }
    });
    messageListView.setOverScrollMode(View.OVER_SCROLL_NEVER);

    // adapter
    items = new LinkedList<>();
    adapter = new ChatRoomMsgAdapter(messageListView, items, container);
    adapter.closeLoadAnimation();
    adapter.setFetchMoreView(new MsgListFetchLoadMoreView());
    adapter.setLoadMoreView(new MsgListFetchLoadMoreView());
    adapter.setEventListener(new MsgItemEventListener());
    adapter.setOnFetchMoreListener(new MessageLoader()); // load from start
    messageListView.setAdapter(adapter);

    messageListView.addOnItemTouchListener(listener);
}
 
Example 13
Source File: MyAmiiboByCategoryFragment.java    From amiibo with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void init(View view) {
    //unset fadin
    try {
        Field field = _grid.getClass().getDeclaredField("_recycler");
        field.setAccessible(true);
        RecyclerView v = (RecyclerView) field.get(_grid);
        v.setFadingEdgeLength(0);
        v.setOverScrollMode(View.OVER_SCROLL_NEVER);
    } catch (Exception e) {
        e.printStackTrace();
    }
    _grid.setRecyclerColumnsListener(this);
    _grid.setRecyclerAdapter(this);
}
 
Example 14
Source File: ListPopup.java    From JianshuApp with GNU General Public License v3.0 4 votes vote down vote up
public ListPopup(Context context) {
    mRecyclerView = (RecyclerView) LayoutInflater.from(context).inflate(R.layout.popup_list, null);
    setContentView(mRecyclerView);
    setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    setFocusable(true);
    setOutsideTouchable(true);
    setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

    mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
    mAdapter = new BaseRecyclerAdapter<CharSequence>(R.layout.item_black_drop_down_menu) {
        @Override
        protected void convert(BaseViewHolder holder, CharSequence data) {
            holder.setText(R.id.tv_name, data);
            holder.setTag(R.id.tv_name, data);
            holder.setOnClickListener(R.id.tv_name, mOriginalOnItemClickListener);

            if (holder.getLayoutPosition() == mSelected) {
                holder.setTextColor(R.id.tv_name, context.getResources().getColor(R.color.theme_color));
            } else {
                holder.setTextColor(R.id.tv_name, Color.GRAY);
            }
        }
    };
    mRecyclerView.setAdapter(mAdapter);

    // 添加阴影
    new CrazyShadow.Builder()
            .setContext(ActivityLifcycleManager.get().current())
            .setDirection(CrazyShadowDirection.ALL)
            .setShadowRadius(DisplayInfo.dp2px(3))
            .setCorner(DisplayInfo.dp2px(2))
            .setBaseShadowColor(Color.LTGRAY)
            .setBackground(Color.WHITE)
            .setImpl(CrazyShadow.IMPL_WRAP)
            .action(mRecyclerView);
    // 避免因添加阴影导致高度变小
    mRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mRecyclerView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            mRecyclerView.getLayoutParams().height = mRecyclerView.getHeight() + DisplayInfo.dp2px(6);
            mRecyclerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });
}