Problem
I’m trying to create a ListView where you can reorder the items by dragging.
This involves hiding the item you’re dragging from the list but an item cannot be completely hidden (setting the height to 0 or setting the visibility to GONE does nothing) so instead I set the visibility to INVISIBLE and the height to 1 but that, of course, causes a small jump when dragging.
Solution
To combat this my goal is to set a negative margin on the item which pulls it up one pixel.
Here comes the problem though, you cannot set margins on a generic view, or rather you can’t do it in code.
You can set a margin in XML and it will work fine but not in code, is there any way around this?
I ended up using a wrapper for the adapter instead.
The adapter moves the “hole” for me instead of creating room for the dragged view.
Since margins does not really work well in android I don’t want use those and paddings will still leave the tiny 1px jump, I think the adapter is the only good solution.