AndroidSwipeLayout 分析
来源:互联网 发布:js参考手册 编辑:程序博客网 时间:2024/05/04 15:08
https://github.com/daimajia/AndroidSwipeLayout
侧滑的删除按钮在右边为例分析:
核心函数:
ViewDragHelper //拉动效果的函数。
打开app,初始化view
<?xml version="1.0" encoding="utf-8"?><com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/godfather" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_gravity="right" android:src="@drawable/bird" android:layout_width="100dp" android:layout_height="100dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="nihao"/></com.daimajia.swipe.SwipeLayout>
1. addView ImageView
2. addView TextView
3. 调了两次onLayout
protected void onLayout(boolean changed, int l, int t, int r, int b) {07-20 19:30:37.926 25279-25279/com.daimajia.swipedemo D/SwipeLayout: onLayout() called with: changed = [true], l = [0], t = [0], r = [480], b = [672]
07-20 19:30:37.976 25279-25279/com.daimajia.swipedemo D/SwipeLayout: onLayout() called with: changed = [false], l = [0], t = [0], r = [480], b = [672]
void layoutPullOut() { // 如果两个view,拼成一个view的。 View surfaceView = getSurfaceView(); // TextView Log.d(TAG, "layoutPullOut: surfaceView:"+surfaceView); Rect surfaceRect = mViewBoundCache.get(surfaceView); if(surfaceRect == null) surfaceRect = computeSurfaceLayoutArea(false); //Rect(0, 0 - 480, 672) 左上(0,0)右下(480,672) if (surfaceView != null) { surfaceView.layout(surfaceRect.left, surfaceRect.top, surfaceRect.right, surfaceRect.bottom); bringChildToFront(surfaceView); } View currentBottomView = getCurrentBottomView();//imageview Rect bottomViewRect = mViewBoundCache.get(currentBottomView); if(bottomViewRect == null) bottomViewRect = computeBottomLayoutAreaViaSurface(ShowMode.PullOut, surfaceRect);//Rect(480, 0 - 630, 672) if (currentBottomView != null) { currentBottomView.layout(bottomViewRect.left, bottomViewRect.top, bottomViewRect.right, bottomViewRect.bottom); }}
layoutPullout效果就是这样的。
1.
onTouchEvent ACTION_DOWN
按第一下,全局变量记录这个点。
2.滑动:
MotionEvent.ACTION_MOVE
1.判断滑动方向2.
mDragHelper.processTouchEvent(ev);
clampViewPositionHorizontal
case Right: if (left > getPaddingLeft()) return getPaddingLeft(); if (left < getPaddingLeft() - mDragDistance) return getPaddingLeft() - mDragDistance; breakreturn left;
0 0
- AndroidSwipeLayout 分析
- AndroidSwipeLayout源码
- AndroidSwipeLayout理解
- AndroidSwipeLayout库的使用
- Swipe RecyclerView using AndroidSwipeLayout
- Android UI Libs之AndroidSwipeLayout
- Android侧滑库AndroidSwipeLayout使用示例
- 在使用AndroidSwipeLayout发现的一些问题
- 很强大的 Swipe Layout:AndroidSwipeLayout
- AndroidSwipeLayout:最强大的 Swipe Layout
- Android 动效系列之一 - AndroidSwipeLayout
- AndroidSwipeLayout:最强大的 Swipe Layout
- AndroidSwipeLayout实现上下左右滑动显示操作按钮
- AndroidSwipeLayout:最强大的 Swipe Layout
- androidSwipeLayout简单用法,仿qq会话列表listview左右滑动
- AndroidSwipeLayout的使用(listview,gridview,view中滑动显示隐藏按钮的使用)
- 分析
- 分析
- 打开关闭窗口【JavaScript】
- android developer tiny share-20160719
- STM32F1学习-串行通信
- js时间类型比较
- LeetCode:Parentheses系列
- AndroidSwipeLayout 分析
- Java基本语法-----java注释
- 【杭电2089】不要62
- POJ 1852 Ants 【水+Trick+贪心】
- 微信运营:自媒体人必须知道的20个自媒体平台
- Markdown 编辑器语法指南
- android---重写textview实现跑马灯
- 【git】git常用命令的学习与总结
- 【HDU1823】Luck and Love-二维线段树