florent37 / ExpansionPanel

Android - Expansion panels contain creation flows and allow lightweight editing of an element.
https://material.io/guidelines/components/expansion-panels.html
Apache License 2.0
1.98k stars 240 forks source link

[BUG] Broken in RecyclerView+SwipeRefreshLayout #63

Open P1NG2WIN opened 4 years ago

P1NG2WIN commented 4 years ago

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)

bhavin1994 commented 4 years ago

did you found any solution?

mythoi commented 3 years ago

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;
    }
}