Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I ran into a similar problem and. To get it working I have a parent layout (contentContainer) which contains 2 subviews:</p> <ul> <li>Content view which is converted to bitmap when curling</li> <li>CurlView (OpenGL Surface)</li> </ul> <p>I had to set an onClickListener to the parent layout to catch the events and send or not send them to the CurlView. When the events are sent to the CurlView, the CurlView is brought to front (using bringToFront() method). Otherwise, the content view is brought to front.</p> <p>To decide if events are sent or not to the CurlView I use a method that returns true if the tap was within the page curl area (aprox. 1/6 of the screen, both sides). Additionally I have a gesture and scale detectors to detect singleTap and longPress, which is what we need for user interaction. When a singleTap or longPress is catched, the postion (x,y) tells me where the user touched so I can launch some activity, show a context menu or whatever.</p> <p>Some sample code:</p> <pre><code> contentContainer.setOnClickListener(null); // DO NOT REMOVE THIS, IT'S A WORKAROUND contentContainer.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { gestureDetector.onTouchEvent(event); mScaleDetector.onTouchEvent(event); int x = (int)event.getX(); int y = (int)event.getY(); boolean isMoving = event.getAction() == MotionEvent.ACTION_MOVE; boolean isTouchDown = event.getAction() == MotionEvent.ACTION_DOWN; boolean isTouchUp = event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL; boolean pageCurlArea = isPageCurlArea(x, y); boolean sendEventToCurlView = false; if (isTouchDown &amp;&amp; pageCurlArea) { downInPageArea = true; sendEventToCurlView = true; } else if (downInPageArea &amp;&amp; isMoving) { sendEventToCurlView = true; } else if (downInPageArea &amp;&amp; isTouchUp) { downInPageArea = false; sendEventToCurlView = true; } else if (!downInPageArea &amp;&amp; isMoving) { return false; } if (downInPageArea &amp;&amp; isMoving &amp;&amp; !curlViewIsOnTop) { bringCurlViewToFront(); } if (sendEventToCurlView) { MotionEvent mEvent = MotionEvent.obtain(event); mCurlView.onTouch(v, mEvent); } return !sendEventToCurlView; } }); </code></pre> <p>It is a work in progress yet, because I need to modify it to not use "page curl area" to discriminate between "curl event" and other events (singleTap, longPress...), for which I plan to use both the gesture and scale detectors to return if an event was catched and depending on the result, continue sending the event to the CurlView or not. This is necessary to perform "taps" and "longPress" within the 1/6 page curl area.</p> <p>Hope it helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload