i'm using a SemiClosedSlidingDrawer (http://pastebin.com/FtVyrcEb) and i've added on content part some buttons on the top of slider which are always visibles.
The problems is that they are clickable (or click event is dispatched) only when slider is fully opened...
When slider is "semi-opened" click event not seems dispached to button...
I have inspected with debugger into onInterceptTouchEvent() and in both cases (opened/semi-collapsed) the following code
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (mLocked) {
return false;
}
final int action = event.getAction();
float x = event.getX();
float y = event.getY();
final Rect frame = mFrame;
final View handle = mHandle;
handle.getHitRect(frame);
//FOLLOWING THE CRITICAL CODE
if (!mTracking && !frame.contains((int) x, (int) y)) {
return false;
}
return false but only when slider is opened event was dispached... It checks if a (x,y) relative to the click are contained in a rectangle created starting from the HandleButton view of sliding drawer...
final Rect frame = mFrame;
final View handle = mHandle;
handle.getHitRect(frame);
and this is obviously false because i'm clicking on a button contained inside the content part of slidingdrawer and that's ok...
As i said above the problem is that in semi-collapsed state, buttons contained in content part are not receiving the event...
Have you any idea how can i solve this issue?
Can be some state of slidingdrawer that avoid to click childs when collapsed?
Thanks in advance...
Right, I think I've figured out a way to do this.
First you need to modify
onInterceptTouchEvent()
to returntrue
whenever the user presses the visible content during the semi-opened state. So, for instance, if yourSemiClosedSlidingDrawer
view is located at the very bottom of the screen, you can use a simple detection algorithm, like this:Now the touch events during the user's interaction with the semi-opened content will be dispatched to
onTouchEvent()
. Now we just need to intercept these events and "manually" redirect them to the right view (note that we also need to offset the coordinates for the child view):It's a bit of a messy implementation, but I think the basic concept is right. Let me know how it works for you!