Open dzielins42 opened 4 years ago
There is a rather hacky way to walk around it.
Implementing getActivationElevation
as below will trick ItemTouchUIUtilImpl
.
@Override
public float getActivationElevation() {
itemView.setTag(R.id.item_touch_helper_previous_elevation,50f);
return (Float)itemView.getTag(R.id.item_touch_helper_previous_elevation);
}
Hello, I came up with an issue. I've tried to implement simple list with draggable items. Dragged item has to have elevation (shadow). I've tried to use
getActivationElevation
but it does not work as described in wiki.According to Wiki,
getActivationElevation
returns value of desiredelevation
when view is activated (eg. dragged), however this value is not applied correctly.I've done some investigation myself.
FlexibleViewHolder.toggleActivation
correctly callsViewCompat.setElevation
with value fromgetActivationElevation
. However, this is quickly overwritten byItemTouchUIUtilImpl.onDraw
. The newelevation
value is1f + findMaxElevation(...)
, andfindMaxElevation
ignores dragged item. This means that, if my base items have no elevation, dragged item will have elevation1f
no matter what value is returned bygetActivationElevation
.This is easily reproducible in demo app, just change value returned in
Simple.getActivationElevation
to see that it has no effect or removeelevation
from rootRelativeLayout
inrecycler_header_item.xml
to see that it will change elevation of item to1f
.