Open samwaxman opened 5 years ago
@samwaxman Thank you for report.
I already know this issue and try to resolve. But it is difficult because we can't identify manual swipe or automatic swipe in CardStackLayoutManager
especially in scrollHorizontallyBy
and scrollVerticallyBy
. So we can't block manual swipe while running automatic swipe.
Do you have any idea to resolve this issue? And your contribution is welcome!
@samwaxman there's a hack way to solve this issue temporarily. you can add another view to cover on the cardStackView. And then add a scrollListener for cardStackView, when it comes to scrolling, show the cover view to intercept touch event.
cardStackView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
coverView.setVisibility(View.GONE);
} else {
coverView.setVisibility(View.VISIBLE);
}
}
});
make sure your cover view is transparent and can handle touch event:
android:background="@android:color/transparent"
android:clickable="true"
android:focusable="true"
I've set
manager.setSwipeableMethod(SwipeableMethod.Automatic)
and it works, but it fails when an automatic swipe begins. There's a gif below. The expected behavior is that I shouldn't be able to start dragging it.