4

GestureOverlayView を保持するウィジェットを作成することは可能ですか?

私の目標は、ジェスチャー パッドの左側に 4 つのボタンを重ねたウィジェットを作成することです。私のアクティビティとフラグメントでは、現在 GestureOverlayView を使用しています。これにより、ジェスチャを読み取り、それらを保存されたジェスチャ パターンのライブラリと照合して、特定のアクションを決定できます。

プロジェクトのこの次のフェーズでは、フラグメントとアクティビティにあるジェスチャ ペインを、Android のホーム画面に配置されたウィジェットに複製したいと考えています。

Android で FrameLayouts が許可されているという記事を読み、GestureOverlayView がフレームレイアウトからどのように拡張されているかを見て、理想主義的な自己認識でこれが可能であると考えました。

これまでのところ、使用したいのと同じ画像とレイアウトを備えたウィジェットを取得しましたが、機能がなくても問題なく表示されます。レイアウトは次のとおりです。

<?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:layout_width="fill_parent" android:layout_height="1dip" 
                android:background="#FFFFFF" android:layout_centerVertical="true" /> <ImageView 
                android:layout_height="30dip" android:src="@drawable/call" android:layout_width="wrap_content" 
                android:scaleType="centerInside" android:layout_centerHorizontal="true" /> 
                <LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content" 
                android:layout_centerInParent="true"> <ImageView android:layout_height="30dip" 
                android:src="@drawable/text" android:layout_width="wrap_content" android:scaleType="centerInside" 
                android:layout_marginTop="30dip" /> </LinearLayout> -->

            <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>

ジェスチャー ビューを追加すると、次のようになります。

<?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:layout_width="fill_parent" android:layout_height="1dip" 
                android:background="#FFFFFF" android:layout_centerVertical="true" /> <ImageView 
                android:layout_height="30dip" android:src="@drawable/call" android:layout_width="wrap_content" 
                android:scaleType="centerInside" android:layout_centerHorizontal="true" /> 
                <LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content" 
                android:layout_centerInParent="true"> <ImageView android:layout_height="30dip" 
                android:src="@drawable/text" android:layout_width="wrap_content" android:scaleType="centerInside" 
                android:layout_marginTop="30dip" /> </LinearLayout> -->

            <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>

このウィジェットをホーム画面に追加すると、「ウィジェットの読み込みに問題があります」というメッセージが表示されます

次に、ドキュメントの次の部分を見つけました。

「ウィジェットは「ミニアプリ」として理解できますが、ウィジェットの設計に着手する前に理解しておくことが重要な特定の制限があります。

ジェスチャー

ウィジェットはホーム画面に存在するため、そこで確立されたナビゲーションと共存する必要があります。これにより、フルスクリーン アプリと比較して、ウィジェットで利用できるジェスチャー サポートが制限されます。たとえば、アプリは、ユーザーが画面間を横方向に移動できるようにするビュー ページャーをサポートしている場合がありますが、そのジェスチャーは、ホーム パネル間を移動する目的でホーム画面に既に適用されています。

ウィジェットで使用できる唯一のジェスチャは次のとおりです。

タッチ 縦スワイプ」

http://developer.android.com/design/patterns/widgets.html

これは、このビューを使用できないということですか?

4

0 に答える 0