如图
或者是这样,不需要一句代码,只需要改布局
仔细观察,每一个item有翻转的效果,但是每一个item的翻转度数不一样。一般的话,大家会重新定义一个layoutmanger然后如同写viewgrounp的方式来实现这个效果,比如根据item的postion来改变拉伸x,y的长度和y的旋转度数。
但是那天突然想到一个不需要写程序只改布局的方法。
首先我们看原图,也就是下图左边的item
扫描二维码关注公众号,回复:
8510423 查看本文章
只需要让recylerVIew的旋转度数和itemview刚好相反
代码很简单,在让itemView的xml根布局旋转的角度和recylerView旋转的角度相反
比如
在item.xml根布局加上 android:rotationX="-25"
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/cardview_layout_hight"
android:scaleX="0.9"
android:scaleY="0.9"
android:rotationX="-25"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardBackgroundColor="#ffffff"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginBottom="1dp"
android:clickable="true"
android:id="@+id/cd"
android:translationZ="1dp"
android:foreground="?android:attr/selectableItemBackground"
app:cardCornerRadius="2dp"
app:cardElevation="1dp"
app:cardUseCompatPadding="true"
app:cardPreventCornerOverlap="false">
>
让在recylerView的布局中加上 android:rotationX="15"
<android.support.v7.widget.RecyclerView
android:translationY="-80dp"
android:rotationX="15"
android:id="@+id/rec"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
效果
同理也可以实现这种效果
没有什么难度,实现起来也很简单。
宣布原创,欢迎转载或者评论