Android4.0以下View的Drag和Drop简单实现主要代码部分:实现View的onTouch方法,变换落点的X,Y坐标,定义两个
Android4.0以下View的Drag和Drop简单实现
主要代码部分:
实现View的onTouch方法,变换落点的X,Y坐标,定义两个变量存放拖动前的坐标位置.
<?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/Board" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="top" > <View android:id="@+id/Pawn" android:layout_width="40dp" android:layout_height="40dp" android:layout_gravity="top" android:background="@drawable/ic_launcher" > </View></FrameLayout>
