1、创建监听的view和被拖曳的view,这里以TextView和ImageView为例
<TextView
android:id="@+id/removethis"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="拖到此处删除"
android:textStyle="bold" />
<ImageView
android:id="@+id/imagetl"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginStart="150dp"
android:background="@color/black_40"
android:scaleType="centerInside"
android:src="@drawable/delete"/>
2、activity代码
//实例化view
TextView removestv = findViewById(R.id.removethis);
ImageView imagetl = findViewById(R.id.imagetl);
//开始拖曳
imagetl.setOnLongClickListener(new View.OnLo