How to get dragshadow visibility

So I am using longclicklistener and in longclick I want to start dragging. This works very well, but there is a special case where I want to add the first view to the layout and then start dragging with the added view.

When I do this everything works well, but the dragshadow is not visible. I am using a custom shadowbuilder but it is ok with scaling and I tried it with a normal shadowbuilder too. Dragging works as it should, but no shadows appear. My code looks like this:

View.OnLongClickListener longlistener = new View.OnLongClickListener() {
    @Override
    public boolean onLongClick(View v) {
        ...
        LinearLayout another = copy(v); //making copy of view
        //doing some changes on it
        ((LinearLayout) v.getParent()).addView(another); //adding it on parent

        //starting drag like normal
        ClipData clipdata = ClipData.newPlainText("", "");
        View.DragShadowBuilder shadowbuilder = new MyDragShadowBuilder(another);
        v.startDrag(clipdata, shadowbuilder, another, 0);


        return true;
    }
};

      

I have also tried this

another.startDrag(clipdata, shadowbuilder, another, 0);

      

+3


source to share





All Articles