Android实现探探图片滑动效果

  

之前一段时间,在朋友的推荐下,玩了探探这一款软件,初玩的时候,就发现,这款软件与一般的社交软件如陌陌之类的大相径庭,让我耳目一新,特别是探探里关于图片滑动操作让人觉得非常新鲜。所以在下通过网上之前的前辈的经历加上自己的理解,也来涉涉水。下面是网上找的探探的原界面
  

  

 Android实现探探图片滑动效果”> <br/>
  </p>
  <p>当时就非常想通过自己来实现这种仿探探式的效果,然而却没什么思路。不过毋庸置疑的是,这种效果的原理肯定和列表视图/RecyclerView类似,涉及到项目视图的回收和重用,否则早就因为大量的项目视图而伯父了。<br/>
  从视图入手,RecyclerView是自带项目视图回收和重用功能的,而且,RecyclerView的布局方式是通过设置LayoutManager来实现的,这样就充分地把布局和RecyclerView搞定了。<br/>
  </p>
  <p>继承RecyclerView。LayoutManager,显示自己管理布的局,比如最多显示4个视图,并且都是居中显示。<br/>
  底部的观点还需要进行缩放,平移操作。</p>
  
  <pre类=   公共类OverLayCardLayoutManager RecyclerView延伸。LayoutManager {   私有静态最终字符串标签=皊wipecard”;   公共静态int MAX_SHOW_COUNT=4;   公共静态浮动SCALE_GAP f=0.05;   公共静态int TRANS_Y_GAP;      公共OverLayCardLayoutManager(上下文语境){//平移时,需要用到的参考值   TRANS_Y_GAP=(int) (20 * context.getResources () .getDisplayMetrics () .density);   }      @Override   公共RecyclerView。LayoutParams generateDefaultLayoutParams () {//必须要实现的方法   返回新RecyclerView.LayoutParams (ViewGroup.LayoutParams。WRAP_CONTENT ViewGroup.LayoutParams.WRAP_CONTENT);   }      @Override   公共空间>   公共类RenRenCallback ItemTouchHelper延伸。SimpleCallback {      私有静态最终字符串标签=叭巳送?   私有静态最终int MAX_ROTATION=15;>   & lt; LinearLayout xmlns: android=" http://schemas.android.com/apk/res/android "   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_gravity=" center_horizontal |底”   android: layout_marginBottom=" 20 dp”   面向android:="水平"比;      & lt; ImageView   android: id=癅 +左/id”   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_gravity="中心"   android: layout_margin=" 10 dp”   android:背景=" @drawable/home_buttons_dislike”   android: onClick="左"/比;      & lt; ImageView   android: id=癅 + id/信息”   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_gravity="中心"   android: layout_margin=" 10 dp”      android:背景=癅drawable/home_buttons_info”/比;      & lt; ImageView   android: id=癅 + id/右”   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_margin=" 10 dp”   android:背景=" @drawable/home_buttons_like”/比;      & lt;/LinearLayout>   之前      

布局文件:点击按钮

  

        & lt; & # 63; xml version=" 1.0 " encoding=" utf - 8 " & # 63;比;   & lt; LinearLayout xmlns: android=" http://schemas.android.com/apk/res/android "   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_gravity=" center_horizontal |底”   android: layout_marginBottom=" 20 dp”   面向android:="水平"比;      & lt; ImageView   android: id=癅 +左/id”   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_gravity="中心"   android: layout_margin=" 10 dp”   android:背景=" @drawable/home_buttons_dislike”   android: onClick="左"/比;      & lt; ImageView   android: id=癅 + id/信息”   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_gravity="中心"   android: layout_margin=" 10 dp”      android:背景=癅drawable/home_buttons_info”/比;      & lt; ImageView   android: id=癅 + id/右”   android: layout_width=" wrap_content "   android: layout_height=" wrap_content "   android: layout_margin=" 10 dp”   android:背景=" @drawable/home_buttons_like”/比;      & lt;/LinearLayout>   

Android实现探探图片滑动效果