First of all, I saw this question: Adding a colored background with text/icon under swiped row when using Android's RecyclerView
However, even though the title s
I was investigating the same issue. What i ended up doing was, in the layout that contained the recyclerView, I added a simple FrameLayout called 'swipe_bg' of the same height as one of my RecyclerView.ViewHolder items. I set its visibility to "gone", and placed it under the RecyclerView
Then in my activity where i set the ItemTouchHelper, I override the onChildDraw like so..
final ItemTouchHelper.SimpleCallback swipeCallback = new ItemTouchHelper.SimpleCallback(0,
ItemTouchHelper.LEFT|ItemTouchHelper.RIGHT){
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
View itemView = viewHolder.itemView;
swipe_bg.setY(itemView.getTop());
if(isCurrentlyActive) {
swipe_bg.setVisibility(View.VISIBLE);
}else{
swipe_bg.setVisibility(View.GONE);
}
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
};
Don't know if that is the best way, but seemed like the simplest way.