[英]Android RecyclerView with flipping CardView
我的RecyclerView提供了受Android-SwipeToDismis启发可以弃用(刷卡)的卡片列表。 这部分正在工作。
现在添加了动画来像这样翻转卡片。
final AnimatorSet setRightOut = (AnimatorSet) AnimatorInflater.loadAnimator(mActivity, R.animator.flip_right_out);
final AnimatorSet setLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(mActivity, R.animator.flip_left_in);
setRightOut.setTarget(swipeView);
setLeftIn.setTarget(backView);
setRightOut.start();
setLeftIn.start();
swipeView是被刷过的CardView。 backView是CardView,它应该通过翻转动画来代替swipeView。
当我两次使用swipeView时,一切正常。 因此它将360度翻转回自身。 但是我似乎无法显示其他任何内容。
如何正确实现backView? 在我的布局XML下面。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_front"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
card_view:cardElevation="@dimen/card_elevation">
<LinearLayout ....</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_back"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
card_view:cardElevation="@dimen/card_elevation">
<LinearLayout ....</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
经过进一步的调查,看起来那里是视图,但Alpha =0。这是触发翻转动画之前来自日志的一些信息:
RecyclerFragment:ViewHolder {418f3088 position = 1 id = -1,oldPos = -1,pLpos:-1} RecyclerFragment:getBackCard:android.widget.RelativeLayout {418f1ab8 VE .... 0,0-0,0} RecyclerFragment:swipeView:android.widget.RelativeLayout {418eda10 VE..C。 ........ 0,-13-480,638} RecyclerFragment:LP:android.widget.RelativeLayout$LayoutParams@418dc2b8 RecyclerFragment:backView:android.widget.RelativeLayout {418f1ab8 VE .... ......一世。 0,0-0,0}
翻转动画后触摸swipView时,可以将其拖动并显示原始CardView旋转180度。 我可以再次翻转,但仍然不显示任何内容。 但是,触摸不显示任何内容。 任何想法都欢迎!
问题是swipeView是RelativeLayout,而backView是CardView。 添加; 最终视图frontView = swipeView.findViewById(R.id.front_card);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.