Search code examples
androidgesture

GestureOverlayView not working perfectly on layout


I am currently working on a project which include Gestures. It's work perfectly but i want put padding or margin on gesture but not layout change which i want. How to put padding or margin in gestures?

my xml code:

<FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1.50"
            android:layout_marginTop="5dp"
            android:layout_gravity="center" >

            <ImageView
                android:id="@+id/imageView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/bg_alpha"
                android:layout_gravity="center"
                android:contentDescription="@string/app_name" >
            </ImageView>

            <android.gesture.GestureOverlayView
                android:id="@+id/draw_on_gesture"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_margin="15dp"
                android:background="@drawable/a_draw" 
                android:eventsInterceptionEnabled="true">
            </android.gesture.GestureOverlayView>

        </FrameLayout>

Solution

  • Take a look at this:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    />
    <android.gesture.GestureOverlayView
    android:id="@+id/gestures"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gestureStrokeType="multiple"
    android:eventsInterceptionEnabled="true"/>
    </LinearLayout>
    

    Also refer to this link, it may help also.