ExpansionPanel icon indicating copy to clipboard operation
ExpansionPanel copied to clipboard

[BUG] Broken in RecyclerView+SwipeRefreshLayout

Open P1NG2WIN opened this issue 4 years ago • 2 comments

Due to the fact that ExpansionLayout is inherited from NestedScrollView, when this element is placed in SwipeRefreshLayout it intercepts touch events and breaks the swipe (you can test it by yourself). In theory, this should be fixed through nestedScrollingEnabled = "false" but NestedScrollView does not allow this. How to fix it? (Why is there NestedScrollView at all, I think that if I needed it, I would add it to my layout)

P1NG2WIN avatar Mar 30 '20 12:03 P1NG2WIN

did you found any solution?

bhavin1994 avatar Jul 25 '20 09:07 bhavin1994

Intercept related event by extends ExpansionLayout

 public class NoScrollExpansionLayout extends ExpansionLayout {

    public NoScrollExpansionLayout(Context context) {
        super(context);
    }

    public NoScrollExpansionLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public NoScrollExpansionLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        // 不拦截这个事件
        return false;
    }

    @SuppressLint("ClickableViewAccessibility")
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        // 不处理这个事件
        return false;
    }

    @Override
    public boolean executeKeyEvent(@NonNull KeyEvent event) {
        // 不响应按键事件
        return false;
    }
}

mythoi avatar May 16 '21 06:05 mythoi