-1

I'm using cards to show a list in a recycler view and have implemented Swipe-To-Show-Background feature. But I'm struggling to figure out how to dynamically add a view underneath the card which doesn't get moved but gets displayed when the top view item gets moved?

I can't obviously have the back-view and front-view in the same card, as they both will get swiped.

Edit: So, I've a card view that has swipe left/right feature. I want to show a view in its background when swiped right. My biggest issue here is I'm not able to dynamically add a view and make it visible when the card is swiped.

IamH1kc
  • 6,602
  • 4
  • 19
  • 17

1 Answers1

2

I don't have enough reputation to comment so i am posting this as answer.

Firstly, please elaborate your question properly it is a bit vague. Meanwhile, to change background dynamically you can try setBackgroundResource(R.drawable.xxx)

rusted brain
  • 1,052
  • 10
  • 23
  • Have done a bit more of editing. Does that help? No, don't want to show a drawable. Want to show a view. – IamH1kc Jul 11 '15 at 10:36
  • Ok i got your question. You can try this make a layout file which will be invisible, when you swipe your card, make the visibility of the card to GONE by writing setVisibility(View.GONE); it will remove the space take by the card then make your background layout visible, it will be shown in the same place as of space taken by card. I am not sure about this but you can try. – rusted brain Jul 11 '15 at 10:45
  • As I've said, layout inside the card gets swiped along with the card. Thus the idea of declaring a separate layout/view and dynamically adding it to the background outside of the card. – IamH1kc Jul 11 '15 at 10:50
  • You marked it correct but did that work? I thought of different mechanism though, you can add views at run time. So on swipe add the view which you want to show. – rusted brain Jul 11 '15 at 10:56
  • Also see this question http://stackoverflow.com/questions/27623741/hide-view-behind-another-view-in-android – rusted brain Jul 11 '15 at 10:57