显示并拖动位于其他视图顶部的视图

时间:2013-03-14 19:36:32

标签: android drag-and-drop android-custom-view

我需要显示视图,也可以将其拖动到屏幕上的所需位置。此视图可以作为叠加层拖动到其他视图之上。如何实现这一点。我的布局可能如下所示

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<ImageView 
    android:id="@+id/image1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
 />
<ImageView 
    android:id="@+id/image2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
/>

<org.example.MyCustomDrabaleView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
 />

实际上我正在尝试构建一个示例库项目,开发人员可以使用我的MyCustomDrabaleView视图并拖动他们的视图。我很惊讶如何获取MyCustomDrabaleView的触摸事件,以便当它被拖动时我可以更新它查看其新职位。

0 个答案:

没有答案