使透明画布不透明(尝试通过Android中的拖放覆盖默认的DragShadow外观)

Gee*_*ugs 5 android drag-and-drop

拖动阴影的默认外观和位置是过去的视图透明且以触摸为中心.我希望它看起来很稳固,视图从你的触摸开始.

我已经下了DragShadowBuilder并覆盖了"onProvideShadowMetrics"和"onDrawShadow".我有我想要的定位,但我不知道如何关闭透明.

这是触摸侦听器,调用创建我的dragShadowBuilder和dragShadowBuilder类:

private OnTouchListener onTouchListener = new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            Item current = (Item) ((View) v.getTag()).getTag();
            //ClipData data = ClipData.newPlainText("test", "testText");
            View dragView = (View) v.getTag();//the on touch view is just the "grid" image.  It holds the whole view in it's tag
            DragShadowBuilder shadowBuilder = new ItemDragShadowBuilder(dragView, 
                                new Point(v.getWidth()/2, v.getHeight()/2));
            v.startDrag(null, shadowBuilder, current, 0);
            dragView.setVisibility(View.INVISIBLE);
            return true;
        } else {
            return false;
        }       
    }

};

private static class ItemDragShadowBuilder extends View.DragShadowBuilder {

    private Point touchPoint = null;
    private Point sizePoint = null;
    private View dragView = null;

    public ItemDragShadowBuilder(View dragView, Point touchPoint) {
        super();
        sizePoint = new Point(dragView.getWidth(), dragView.getHeight());
        this.touchPoint = touchPoint;
        this.dragView = dragView;
    }

    @Override
    public void onProvideShadowMetrics (Point size, Point touch) {
        size.set(sizePoint.x, sizePoint.y);
        touch.set(touchPoint.x,touchPoint.y);
    }

    @Override
    public void onDrawShadow(Canvas canvas) {
        dragView.draw(canvas);
        //How do I change the transparency?
        //super.onDrawShadow(canvas);
    }



}
Run Code Online (Sandbox Code Playgroud)

这是我当前正在拖动项目的屏幕:

我目前的屏幕

注意透明的外观.当您长按订阅并选择"重新订购"时,我希望它看起来类似于下面的Google当前应用.您会注意到视图看起来很稳固.

Google Currents

如何让我的拖影固定?