I know I can change the target when the shadow is over it, but I really want to change the shadow to indicate the action that will be performed to it when it is over the target.
I am able to modify the DragShadowBuilder when it is constructed by changing the output of onProvideShadowMetrics & onDrawShadow.
I have gone so far to add some public methods which can be accessed by the target and trying to update a class variable which holds the canvas & view, but it looks like it does not actually update when changes are made. This is my public method which gets called when the shadow is over the target.
public void onTarget(String string) {
mView.draw(mCanvas);
Paint redPaint = getFillTextPaint(0.00003f, 0xFFFF0000, 0.05225f);
RectF r = new RectF();
r.set(mCanvas.getWidth()-100.0f, 0,mCanvas.getWidth(), mCanvas.getHeight());
mCanvas.drawRoundRect(r,8.0f,8.0f, redPaint);
mView.invalidate();
}
Thanks,
DragShadowBuilder.onDrawShadow() is invoked by View.startDrag() at the beginning of the drag and drop process.
Unfortunately native Drag and Drop, which was introduced with API level 11, does not support changing the bitmap after start.
Alternatively, you could roll your own Drag and Drop mechanism as shown, for example, here and here, as it was done before API level 11.