zoukankan      html  css  js  c++  java
  • 关于recycler遇到的问题

    1.//设置recyclerView不能点击
    myLayoutManager.setScrollEnabled(false);
    class MyLayoutManager extends LinearLayoutManager { private boolean isScrollEnabled = true; public MyLayoutManager(Context context) { super(context); } public MyLayoutManager(Context context, int orientation, boolean reverseLayout) { super(context, orientation, reverseLayout); } public MyLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } public void setScrollEnabled(boolean flag) { this.isScrollEnabled = flag; } @Override public boolean canScrollVertically() { //isScrollEnabled:recyclerview是否支持滑动 //super.canScrollVertically():是否为竖直方向滚动 return isScrollEnabled && super.canScrollVertically(); } }

    2.//屏蔽滑动事件 
    public class BanScrollview extends ScrollView {
    private int downX;
    private int downY;
    private int mTouchSlop;

    public BanScrollview(Context context) {
    super(context);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    }

    public BanScrollview(Context context, AttributeSet attrs) {
    super(context, attrs);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    }

    public BanScrollview(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
    int action = e.getAction();
    switch (action) {
    case MotionEvent.ACTION_DOWN:
    downX = (int) e.getRawX();
    downY = (int) e.getRawY();
    break;
    case MotionEvent.ACTION_MOVE:
    int moveY = (int) e.getRawY();
    if (Math.abs(moveY - downY) > mTouchSlop) {
    return true;
    }
    }
    return super.onInterceptTouchEvent(e);
    }
    }

    3.scrollView中嵌套recyclery时,当界面显示有recyclerView的数据,这时recycler会有自己的滑动效果,怎么实现滑动的是scrollview呢?我在尝试添加footview
    最后我是在recycler中加了RelativeLayout
  • 相关阅读:
    Matlab高级教程_第一篇:Matlab基础知识提炼_01
    量化投资_量化投资系统框架的DIY_02_01
    计量经济与时间序列_时间序列之物理含义
    计量经济与时间序列_协整和误差修正模型
    数学之美_正态分布(Python代码)
    [转载] ./configure,make,make install的作用
    [转载]Deep Learning(深度学习)学习笔记整理
    AJAX XML 实例
    百度搜索插件源码
    apache 服务器在ubuntu上图片无法显示解决
  • 原文地址:https://www.cnblogs.com/dubo-/p/6836730.html
Copyright © 2011-2022 走看看