-1

I created a custom LayoutManager and TouchHelper.Callback to have a tinder-like card stack. I want my layout manager to allow only the first item to have a touch event. Firstly I override the isItemViewSwipeEnabled() of ItemTouchHelper.Callback to disable touch event for each child. As the last step, I need to allow the first item to have a touch event only. However, I am failed to do so. Is anybody know how to overcome it?

  • StackLayoutManager to create child views.

  • StackTouchHelperCallback to disallow default touch events.

  • StackView a custom RecyclerView.

This is the custom view hierarchy I developed. If anybody developed some kind of views, can them help me? Thanks in advance.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
nuhkoca
  • 1,777
  • 4
  • 20
  • 44

1 Answers1

0

You can override the getMovementFlags method and return 0 in case you dont want to allow any movement, otherwise return appropriate direction flags.

override fun getMovementFlags(recyclerView: RecyclerView, viewHolder:RecyclerView.ViewHolder): Int {
        return if(viewHolder.adapterPosition == 0) /* return appropriate direction flags */ else 0
}
mightyWOZ
  • 7,946
  • 3
  • 29
  • 46
  • Hi @mightyWOZ thanks! I don't have any problems with directions. It is the touch event issue. I disallow the touch event for all children by `isItemViewSwipeEnabled()`. Now I just need to allow a touch event for only the first child. Do you know this is possible and if so how? – nuhkoca Feb 04 '20 at 12:17