モバイルおよびタブレットデバイスで動作する Android 2.3.3 アプリケーションを開発しています。
背景画像付きのメインビューがあります。この画像にはボタンやその他のテキストがあり、それらのボタンの上にクリック可能な領域を作りたいです。これらは実際のボタンではなく、背景画像の一部です。
どうやってやるの?
ImageButton
ボタンを透明にする方法がわからないので、画像なしを使用できるかもしれません。
クリック領域として Framelayout を使用し、ImageView をインジケーターとして使用することができます。例えば :
<FrameLayout
android:id="@+id/play_button_frame"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/button_frame_colors">
<ImageView
android:id="@+id/play_button_indicator"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:src="@drawable/button_indicator"
android:background="@android:color/transparent"/>
</FrameLayout>
You can also place a layout with no background. It will work for sure as you want.
カスタムImageViewを作成し、領域(四角形または座標)を定義し、onTouchイベントをリッスンし、タッチイベントが発生したときにリストを繰り返し処理し、ユーザーが定義された領域に触れた場合に反応します