Skip to content

Elevation is not applied correctly with getActivationElevation  #761

@dzielins42

Description

@dzielins42

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 desired elevation when view is activated (eg. dragged), however this value is not applied correctly.

I've done some investigation myself. FlexibleViewHolder.toggleActivation correctly calls ViewCompat.setElevation with value from getActivationElevation. However, this is quickly overwritten by ItemTouchUIUtilImpl.onDraw. The new elevation value is 1f + findMaxElevation(...), and findMaxElevation ignores dragged item. This means that, if my base items have no elevation, dragged item will have elevation 1f no matter what value is returned by getActivationElevation.

This is easily reproducible in demo app, just change value returned in Simple.getActivationElevation to see that it has no effect or remove elevation from root RelativeLayout in recycler_header_item.xml to see that it will change elevation of item to 1f.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions