高仿花田ios版标签移动效果,长按每一个item拖动到自己想要位置后,后面位置移动补全效果 。
本项目适合研究gridview拖拽效果的朋友下载。本项目主要靠DragGrid来实现,/** 在拖动的情况 */ private void onDrag(int x, int y , int rawx , int rawy) { if (dragImageView != null) { windowParams.alpha = 0.6f;// windowParams.x = rawx - itemWidth / 2;// windowParams.y = rawy - itemHeight / 2; windowParams.x = rawx - win_view_x; windowParams.y = rawy - win_view_y; windowManager.updateViewLayout(dragImageView, windowParams); } }/** 在松手下放的情况 */
private void onDrop(int x, int y) { // 根据拖动到的x,y坐标获取拖动位置下方的ITEM对应的POSTION int tempPostion = pointToPosition(x, y);// if (tempPostion != AdapterView.INVALID_POSITION) { dropPosition = tempPostion; DragAdapter mDragAdapter = (DragAdapter) getAdapter(); //显示刚拖动的ITEM mDragAdapter.setShowDropItem(true); //刷新适配器,让对应的ITEM显示 mDragAdapter.notifyDataSetChanged();// } }
运行效果:
效果源码: