drag-sort-listview icon indicating copy to clipboard operation
drag-sort-listview copied to clipboard

The floating item has black background when it should not

Open hzardaryan opened this issue 11 years ago • 6 comments

I came across with a strange issue when dragged item gets a black background even though the original item's background is transparent. I have also localized the problem, SimpleFloatViewManger.onCreateFloatView():

    v.setDrawingCacheEnabled(true);
    mFloatBitmap = Bitmap.createBitmap(v.getDrawingCache());
    v.setDrawingCacheEnabled(false);

What i did, i just saved the mFloatBitmap to the sdcard and it had the black background. I thing the issue is with v.getDrawingCache(). I have replaced this code with this code snippet:

mFloatBitmap = Bitmap.createBitmap(v.getMeasuredWidth(), v.getMeasuredHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(mFloatBitmap); v.draw(canvas);

And it solved the issue.

hzardaryan avatar Mar 15 '13 12:03 hzardaryan

Or you can override the default float view background color. (which by default is black)

SimpleFloatViewManager simpleFloatViewManager = new SimpleFloatViewManager(mDragSortListView);
simpleFloatViewManager.setBackgroundColor(Color.TRANSPARENT);
mDragSortListView.setFloatViewManager(simpleFloatViewManager);

DHuckaby avatar Mar 15 '13 16:03 DHuckaby

Hello, thanks for the reply. We are using a class that extends SimpleFloatViewManager. setBackgroundColor does not have any effect. The background color is always black. But with the above code, setBackgroundColor does work. It could be because we are using a custom layout for the rows of the list view.

wahnker avatar Mar 15 '13 20:03 wahnker

I also use a custom layout for the list row items, that shouldn't matter.

DHuckaby avatar Mar 18 '13 02:03 DHuckaby

DHuckaby, wahnker means that pretty complex layout is used. That might be the issue.

hzardaryan avatar Mar 18 '13 13:03 hzardaryan

Thanks Dhuckaby.

mustafasevgi avatar Feb 02 '15 13:02 mustafasevgi

Thank You ,It helps a lot

Limuyang1013 avatar Aug 18 '16 08:08 Limuyang1013