动画或更新DragShadowBuilder的视图

时间:2014-05-20 09:45:02

标签: android drag-and-drop

我已经为listview项目实现了拖放操作。这将在LongPress上进行。 initialy DragShadowBuilder绘制具有指定高度和宽度的位图。但我希望减少阴影大小或在动画到达目标时应用淡入淡出。我怎样才能实现这一目标?如何触发阴影消失事件?

长按listview的代码:

@Override
public boolean onItemLongClick(AdapterView<?> l, View v,
                int position, long id) {

            //Selected item is passed as item in dragData
            ClipData.Item item = new ClipData.Item(month.get(position));

            dragView = v;
            dragView.setDrawingCacheEnabled(true);
            Bitmap bmp=getBitmapFromView(v);

            String[] clipDescription = {ClipDescription.MIMETYPE_TEXT_PLAIN};
            ClipData dragData = new ClipData((CharSequence)v.getTag(),
                    clipDescription,
                    item);
            DragShadowBuilder myShadow = new MyDragShadowBuilder(v,month.get(position),bmp,0);

            v.startDrag(dragData, //ClipData
                    myShadow,  //View.DragShadowBuilder
                    month.get(position),  //Object myLocalState
                    0);    //flags
            commentMsg = v.getTag() + " : onLongClick.\n";
            comments.setText(commentMsg);

            dragView.setVisibility(View.INVISIBLE);
            return true;
        }};

我正在动作掉落事件中创建新的DragShadowBuilder。它转到我的函数但它没有更新当前的shadowBuilder。

1 个答案:

答案 0 :(得分:0)

现在已经解决了。我们无法更新DragShadow的视图。所以我只是绘制ACTION_DROP被激活的图像并将动画应用到该imageView。