ユーザーがカードをプレイするシンプルなカードゲームを書いた 3つの画像ビュー(カード)の1つでTAPを実行しています 「テーブル」 (テーブルは別のレイアウトまたは単に画面の別の部分)上のImageViewをドラッグすることによって表示されます。私はtechincを使用するようにしようと試みAndroid:OnTouchEvent for dragを拡張したImageView
が http://blahti.wordpress.com/2011/01/17/moving-views-part-2/ で示されているが、それはAbsoluteLayoutを使用して、それは私の現在のレイアウト上の制約 の多くを紹介し、より多くのそれは、アプリの実行デバイスの画面解像度に に依存調整が必要です。 これを避けたいのですが、 -if possibile- RelativeLayoutを使用してください。 ImageView のonTouchサポートを追加しても再現できない場合があります。 希望の効果(ドラッグ) アイデアや提案やサンプルコードはありますか? ありがとう!
これはちょっとしたアイデアですが、これはレイアウトのドラフトです。 以下の3枚のカードはドラッグで移動する必要があります。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
>
<RelativeLayout android:id="@+id/player_cards_layout"
android:layout_width="fill_parent" android:layout_height="150dip"
android:gravity="center_horizontal"
android:background="#55335588"
android:layout_above="@+id/player_cards_layout"
>
<ImageView android:id="@+id/img_pc_card_1"
android:layout_width="100dip" android:layout_height="150dip"
android:src="@drawable/icon"
/>
</RelativeLayout>
<RelativeLayout android:id="@+id/player_cards_layout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:background="#336699"
>
<ImageView android:id="@+id/img_user_card_1"
android:layout_width="100dip" android:layout_height="150dip"
android:src="@drawable/icon"
/>
<ImageView android:id="@+id/img_user_card_2"
android:layout_width="100dip" android:layout_height="150dip"
android:src="@drawable/icon"
android:layout_toRightOf="@+id/img_user_card_1"
/>
<ImageView android:id="@+id/img_user_card_3"
android:layout_width="100dip" android:layout_height="150dip"
android:src="@drawable/icon"
android:layout_toRightOf="@+id/img_user_card_2"
/>
</RelativeLayout>
</RelativeLayout>
私は決定的なアプローチを変え、私の問題を解決し、使用を開始Blahtiによって提供される方法。彼に感謝! http://blahti.wordpress.com/2011/01/17/moving-views-part-2/ – Lisitso