Is it possible to create a widget containing a GestureOverlayView?
My goal is to create a widget with four buttons on top of eachother, to the left of the gestures. In my actions and snippets, I currently use GestureOverlayView, which allows me to read gestures and map them to a library of saved gesture templates to identify a specific action.
In this next phase of the project, I would like to reproduce my gesture panel, which I have in my fragments and actions, on a widget that is located on the Android main screen.
I read an article that pointed out that FrameLayouts is allowed on Android, because as GestureOverlayView exits framelayout, my idealistic I thought it was possible.
So far I have a widget with the same images and layouts that I want to use, and it displays without functionality just fine. Layout below:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main_layout_app" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight=".2" android:background="@drawable/draw_pad_background" android:orientation="vertical" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/call" /> <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/text" /> <ImageView android:id="@+id/imageView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/app" /> <ImageView android:id="@+id/imageView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/contact" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight=".03" android:background="@drawable/button_divider" android:orientation="vertical" > </LinearLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight=".85" > <LinearLayout android:id="@+id/llSeparateLayer_app" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/llOpenDSR" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight=".5" android:background="@drawable/draw_pad_background" android:gravity="center" > </LinearLayout> </LinearLayout> </RelativeLayout> </LinearLayout>
If I add a gesture view, it will look like this:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/main_layout_app" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" > <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight=".2" android:background="@drawable/draw_pad_background" android:orientation="vertical" > <ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/call" /> <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/text" /> <ImageView android:id="@+id/imageView3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/app" /> <ImageView android:id="@+id/imageView4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/contact" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight=".03" android:background="@drawable/button_divider" android:orientation="vertical" > </LinearLayout> <RelativeLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight=".85" > <LinearLayout android:id="@+id/llSeparateLayer_app" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/llOpenDSR" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight=".5" android:background="@drawable/draw_pad_background" android:gravity="center" > </LinearLayout> </LinearLayout> <android.gesture.GestureOverlayView android:id="@+id/appGestures" android:layout_width="fill_parent" android:layout_height="fill_parent" android:eventsInterceptionEnabled="false" android:fadeOffset="400" android:gestureColor="@color/default_gesture_color" android:gestureStrokeAngleThreshold="0.1" android:gestureStrokeLengthThreshold="80" android:gestureStrokeSquarenessThreshold="0.1" android:gestureStrokeType="multiple" android:orientation="horizontal" android:uncertainGestureColor="@color/default_gesture_color_uncertain" > <ImageView android:id="@+id/image_notification" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> </android.gesture.GestureOverlayView> </RelativeLayout> </LinearLayout>
When I add this widget to my desktop, I get a “Problem loading widget”
Then I found this piece of documentation:
"While widgets can be understood as" widgets, "there are certain limitations that are important to understanding before you start creating your widget:
Gestures
Since widgets live on the main screen, they must coexist with the navigation that is installed there. This limits the gesture support available in widgets compared to a full-screen application. Although applications, for example, can support a presentation pager that allows the user to move between screens in the transverse direction, this gesture has already been made on the main screen to navigate between home panels.
The only gestures available for widgets are:
Touch Vertical Napkin "
http://developer.android.com/design/patterns/widgets.html
Does this mean that I can’t use this view?