Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass click event through the view android

Tags:

android

click

I have frame layout:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="10dp" >

<LinearLayout
    android:id="@+id/widgetView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:layout_margin="10dp"
    android:gravity="center" >
</LinearLayout>

<LinearLayout
    android:id="@+id/widgetOverlayFrame"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="false" >
</LinearLayout>

First layout contains widget layout, and second one is transparent and receives onLongClick for dragging method.That works, the problem is when i want to interact with widget, to click something, click event is taken by overlayFrame. How can i pass click event trough overlayFrame to widgetView?

EDIT:

Now I'm trying to attach GestureLister to overlayFrame LinearLayout, to somehow see difference between MotionEvent that represent single click and long click. The problem that I'm facing is that OnLongPress in gesture listener is always called whatever I do, single click or long click.

Is there an explanation for this behavior? Tnx!

like image 675
Veljko Avatar asked Nov 21 '12 08:11

Veljko


1 Answers

In my case I added flag to layoutParams of my view, which should have passed a touch event under:

WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE

This way view will ignore all touches (like view with visibility GONE)

like image 114
Eugene Voronoy Avatar answered Sep 27 '22 23:09

Eugene Voronoy