マルチタッチ

水曜日に touch&try があるのでサンプルを試してみようかな、と。どうせ 2.2 なら C2DM 試せよ、って話もあるんですが、そのあたりはスルーって事で。(を
以下なサンプルを確認してみます。

ええと、Activity の動作の定義はハロワのまんまです。

package jp.shuri.android.mt;

import android.app.Activity;
import android.os.Bundle;

public class MultiTouch extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
}

まずは res/layout/main.xml を確認する必要がある模様。

<?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">
	<jp.shuri.android.mt.ScalableView 
                android:id="@+id/ImageView01"
		android:layout_width="fill_parent" 
		android:layout_height="fill_parent"
		android:src="@drawable/android" 
		android:focusableInTouchMode="true"
		android:focusable="true" 
		android:clickable="true" 
		android:scaleType="matrix">
        </jp.shuri.android.mt.ScalableView>
</LinearLayout>

id 付けてますがどっかで使ってるのかなぁ。そうでも無いみたいですが。
ええとこの ScalableView は ImageView を継承しているので、そっち方面を確認してみるか。Android Developers なナニによると

  • src は ImageView
    • Sets a drawable as the content of this ImageView.
  • focusableInTouchMode は View
    • Boolean that controls whether a view can take focus while in touch mode.
  • focusable も View
    • Boolean that controls whether a view can take focus.
  • clickable も View
    • Defines whether this view reacts to click events.
  • scaleType は ImageView
    • Controls how the image should be resized or moved to match the size of this ImageView.

との事。なんとなくざっくりな理解だな。

ええと

確認必要な事項を先に列挙しとこ。

  • Matrix というクラス
  • Pointf というクラス
  • onTouch に渡される引数の MotionEvent というクラス

もう少し掘削してみますが、一旦エントリ投入。

メモ

えと、順番としては

  • ACTION_DOWN
  • ACTION_MOVE
  • ACTION_UP

なカンジらしい。マルチタッチな場合は

  • ACTION_POINTER_2_DOWN
  • ACTION_MOVE
  • ACTION_POINTER_2_UP

なのか。なんか MotionEvent のドキュメント見てると ACTION_POINTER_3 というナニが見えるですが、3 本指なタッチで何が起きるのでしょうか。