Flipping CardView in RecyclerView

筅森魡賤 提交于 2019-12-10 18:16:06

问题


I am trying to implement a CardView flip in a RecyclerView. I just cannot figure out a simple solution. I have a working CardView where i can display a list of card using the recycler view. The problem is, how to show the back of the card if user click the card. I want to use animation and change the front of the card to the back of the card. Can someone give a simple animation and example of the card layout. My current example is pretty much copy of this example where a new activity is being created. Where as i need the card to flip 180 degree and show the description. Is the a way to achieve it?

+------------------+ +------------------+
|+----------------+| |+----------------+|
||  front         || ||  back          ||
|+----------------+| |+----------------+|
|+----------------+| |+----------------+|
||  front         || ||  front         ||
|+----------------+| |+----------------+|

回答1:


You could use a ViewFlipper. It's a standard Android widget.




回答2:


I know this is an old question,but this answer may help someone in future.

You can make use of this library

https://github.com/sachinvarma/EasyFlipView

Put this inside your gradle,

compile 'com.github.sachinvarma:EasyFlipView:2.0.4'

The xml will be like,

<com.wajahatkarim3.easyflipview.EasyFlipView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:flipOnTouch="true"
    app:flipEnabled="true"
    app:flipDuration="400"
    app:flipType="vertical" //horizontal or vertical
    >

    <!-- Back Layout Goes Here -->
    <include layout="@layout/flash_card_layout_back"/>

    <!-- Front Layout Goes Here -->
    <include layout="@layout/flash_card_layout_front"/>

</com.wajahatkarim3.easyflipview.EasyFlipView>

You can see a demo gif here.

Thanks to Wajahat karim.



来源:https://stackoverflow.com/questions/31325293/flipping-cardview-in-recyclerview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!