KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am developing for api > 14 and I have implemented drag/drop functionality on a GridView . However, while dragging items to the top or bottom of the screen the GridView does not scroll. I would like to have it scroll in the direction you drag an item getting faster as you move to the edge and slow as you move the item back towards the vertical center of the screen. Surely this sort of functionality should be standard in any drag-n-drop? Anyway, does anyone know the best way to approach this? UPDATE : I can't actually find a single example on the internet that even attempts to scroll with a dragged grid item (am I missing something here?) let alone solve my problem. How do you get the draggable item (that appears as a shadow) to scroll the gridview? I am assigning the drag as follows: int gridChildPosition = position - mGridView.getFirstVisiblePosition(); ViewFlipper gridItem = (ViewFlipper) mGridView.getChildAt(gridChildPosition); ClipData data = ClipData.newPlainText("", ""); DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(gridItem); if (mGridView.startDrag(data, shadowBuilder, gridItem, 0)) { int lastVisiblePosition = mGridView.getLastVisiblePosition() - mGridView.getFirstVisiblePosition(); for (int i=0; i<=lastVisiblePosition; i++) { if (i == gridChildPosition) { continue; } mGridView.getChildAt(i).setOnDragListener(new GridItemDragListener(position)); mGridView.getChildAt(i).setAlpha(0.4f); } } Above code creates the draggable shadow and all other items currently get dimmed. But I'm unsure how I can get the shadow to scroll the gridview.
Tags (comma-separated)
Save Edits
Cancel