diff --git a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java index 424a008c..3dcb1286 100644 --- a/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java +++ b/library/src/main/java/com/sothree/slidinguppanel/SlidingUpPanelLayout.java @@ -208,6 +208,8 @@ public enum PanelState { */ private boolean mIsTouchEnabled; + private OnBackgroundClick mBackgroundListener; + private float mPrevMotionX; private float mPrevMotionY; private float mInitialMotionX; @@ -966,6 +968,14 @@ public boolean dispatchTouchEvent(MotionEvent ev) { final float x = ev.getX(); final float y = ev.getY(); + if (!isViewUnder(mSlideableView, (int)x, (int)y)) { + if (mBackgroundListener != null) { + mBackgroundListener.onClick(); + } + + return false; + } + if (action == MotionEvent.ACTION_DOWN) { mIsScrollableViewHandlingTouch = false; mPrevMotionX = x; @@ -1144,6 +1154,10 @@ private void setPanelStateInternal(PanelState state) { dispatchOnPanelStateChanged(this, oldState, state); } + public void setOnBackgroundClicked(OnBackgroundClick listener) { + mBackgroundListener = listener; + } + /** * Update the parallax based on the current slide offset. */ @@ -1487,4 +1501,8 @@ public LayoutParams(Context c, AttributeSet attrs) { } } + + public interface OnBackgroundClick { + void onClick(); + } }