Почему после перемещения ImageView фигура не возвращается в свое первоначальное состояние и так и останется навсегда спрятанной?
OnTouchListener onTch = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
ClipData clipData = ClipData.newPlainText("", "");
View.DragShadowBuilder dsb = new View.DragShadowBuilder(v);
if (event.getAction() == MotionEvent.ACTION_DOWN) {
Log.d(LOG_TAG, "ACTION_DOWN");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {//.N
Log.d(LOG_TAG, "startDragAndDrop1");
v.startDragAndDrop(clipData, dsb, v, 0);
Log.d(LOG_TAG, "startDragAndDrop2");
} else {
Log.d(LOG_TAG, "startDragAndDrop3");
v.startDrag(clipData, dsb, v, 0);
Log.d(LOG_TAG, "startDragAndDrop4");
}
v.setVisibility(View.INVISIBLE);
Log.d(LOG_TAG, "1234");
return true;
}else {
return false;
}
}
};
imV.setOnTouchListener(onTch);
@Override
public boolean onDrag(View v, DragEvent event) {
Log.d(LOG_TAG, "12");
int action = event.getAction();
View view = (View) event.getLocalState();
switch (action) {
case DragEvent.ACTION_DRAG_STARTED:
// do nothing
Log.d(LOG_TAG, "12345");
return true;
case DragEvent.ACTION_DRAG_ENTERED:
return true;
case DragEvent.ACTION_DRAG_EXITED:
Log.d(LOG_TAG, "12346");
return true;
case DragEvent.ACTION_DROP:
Log.d(LOG_TAG, "12347");
ViewGroup owner = (ViewGroup) view.getParent();
owner.removeView(view);
ConstraintLayout container = (ConstraintLayout) v;
container.addView(view);
view.setVisibility(View.VISIBLE);
return true;
case DragEvent.ACTION_DRAG_ENDED:
Log.d(LOG_TAG, "12348");
view.setVisibility(View.VISIBLE);
return true;
default:
break;
}
return true;
}