DragShadowBuilder - Change shadow when over target?

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 to be taken to it when it is over the target.

I can change the DragShadowBuilder when it is constructed by changing the onProvideShadowMetrics and onDrawShadow output.

So far, I've added some public methods that the target can access and try to update the class variable that contains the canvas and view, but it looks like it doesn't actually update when changes are made. This is my public method that 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();
    }

      

Thank,

+3


source to share


1 answer


DragShadowBuilder.onDrawShadow () is called by View.startDrag () at the start of the drag process.
Unfortunately, the native Drag and Drop that was introduced with API level 11 does not support changing the bitmap after launch.
Alternatively, you can flip your own drag-and-drop mechanism, as shown, for example, here and here , as was done up to API level 11.



+5


source







All Articles