オランダの地図の画像が表示され、州を選択できる Android アプリを作成したいと考えています。各州は別のクラスに移動する必要があります。
私が見つけた最良の方法は、2つの画像でそれを行うことでした.1つはあなたが表示し、もう1つはまったく同じですが、色があります。touchEvent で色を取得し、その Red がクラスに移動するかどうかを確認します。
これまでのところ、2 つの画像を表示しました。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#ffffff" >
<ImageView
android:id="@+id/img_bg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/nl_clickable_original" />
<ImageView
android:id="@+id/img_hitbox"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="fitXY"
android:src="@drawable/nl_clickable"
android:visibility="invisible" />
</FrameLayout>
しかし、今、私はさらに先に進む方法がわかりません。
画像から色を取得する必要がある StackOverflow のコードを見つけましたが、それを実装する方法がわかりません。
private int getColour(int x, int y) {
ImageView img = (ImageView) findViewById(R.id.img_hitbox);
img.setDrawingCacheEnabled(true);
Bitmap hotspots = Bitmap.createBitmap(img.getDrawingCache());
img.setDrawingCacheEnabled(false);
return hotspots.getPixel(x, y);
}
それは正しい方法ですか、それともこれを作成する方法について誰かにもっと良い考えがありますか?
私は今1週間探しているので、少し助けていただければ幸いです:)!
ありがとう