material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[Snackbar] Custom view can't be dragged

Open simoks opened this issue 5 years ago • 3 comments
trafficstars

I have created a custom view extending from the BaseTransientBottomBar class. I can't drag to dismiss this view, so no animation is visible for dragging.

When I'm trying to drag the view, the message below is shown in my logcat console : "Ignoring pointerId=0 because ACTION_DOWN was not received for this pointer before ACTION_MOVE. It likely happened because ViewDragHelper did not receive all the events in the event stream."

class CustomSnackBar (parent: ViewGroup, content: CustomView) : BaseTransientBottomBar< CustomView >(parent, content, content){

..... }

val behavior = Behavior().apply { setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_END_TO_START) setDragDismissDistance(0.3f) }

customSnackBar.setDuration(Snackbar.LENGTH_INDEFINITE).setBehavior(behavior)

Android target and compiled SdkVersion: : 28

Material Library version: tested with 1.1.0, 1.2.0-alpha05, 1.2.0-alpha07 (the same problem)

simoks avatar May 26 '20 12:05 simoks

I'm experiencing this problem with the default SnackBar too, seems to be something to do with it recieving a ACTION_CANCEL event from the CoordinatorLayout when the SwipeDismissBehavior calls requestDisallowInterceptTouchEvent in onViewCaptured.

elliotmurray avatar Jun 27 '20 16:06 elliotmurray

@elliotmurray I'm also experiencing this with the default snackbar. Did you find a solution?

Does this help: https://stackoverflow.com/a/42222170/444761 (also: https://www.codeleading.com/article/43344985927/ )

marcardar avatar Jul 18 '21 06:07 marcardar

Behavior touch event comes from CoordinatorLayout. I think CoordinatorLayout parent requestDisallowInterceptTouchEvent should be used

kingwang666 avatar Jul 13 '22 02:07 kingwang666