compile 'com.nero.ren:SwipeMenu:1.2.0'
<ren.widget.refresh.SwipeMenuRefreshView
android:id="@+id/refresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</ren.widget.refresh.SwipeMenuRefreshView>
<com.daimajia.swipe.SwipeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="80dp"
app:clickToClose="true">
//侧滑出来的布局
<LinearLayout
android:id="@+id/bottom_wrapper_2"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:tag="Bottom4">
<TextView
android:id="@+id/top"
android:layout_width="70dp"
android:layout_height="match_parent"
android:background="#cfcfcf"
android:gravity="center"
android:text="置顶" />
<TextView
android:id="@+id/noread"
android:layout_width="100dp"
android:layout_height="match_parent"
android:background="#ffa500"
android:gravity="center"
android:text="标记未读" />
<TextView
android:id="@+id/delete"
android:layout_width="70dp"
android:layout_height="match_parent"
android:background="#FF0000"
android:gravity="center"
android:text="删除" />
</LinearLayout>
//默认展示的布局
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="80dp">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="aaaaa"
android:textSize="18sp" />
</RelativeLayout>
</com.daimajia.swipe.SwipeLayout>
case MotionEvent.ACTION_DOWN:
pressX = (int) ev.getX(); //记录按下的X坐标
pressY = (int) ev.getY();//记录按下的Y坐标
break;
case MotionEvent.ACTION_MOVE:
//判断滑动距离是否是正常的滑动
if (Math.abs(ev.getY() - pressY) < touchSlop && Math.abs(ev.getX() - pressX) < touchSlop)
return super.onInterceptTouchEvent(ev);
//如果用户是滑动listview则交由父类onInterceptTouchEvent处理
if (interceptStatus == REFRESH_STATUS)
return super.onInterceptTouchEvent(ev);
//用户如果是滑出SwipeLayout则不拦截时间交由SwipeLayout处理
else if (interceptStatus == SWIPE_MENU_OPEN)
return false;
//根据滑动角度判断用户是滑出SwipeLayout还是Listview
double angle = Math.atan((ev.getY() - pressY) / (ev.getX() - pressX));//计算滑动的角度
int degrees = (int) Math.toDegrees(angle);
degrees = Math.abs(degrees);
//大于45度则判断为Listview滑动
if (degrees > 45) {
Log.d(TAG, "正在上下滑动");
//如果当前是SwipeLayout内点击的事件序列则不允许滑动
if (interceptStatus == SWIPE_MENU_CLOSE)
return true;
interceptStatus = REFRESH_STATUS; //标记为Listview滑动
return super.onInterceptTouchEvent(ev);
} else { //小于45度则判断为SwipeLayout滑动
Log.e(TAG, "正在左右滑动");
currentSwipeLayout = getCurrentSwipeLayout(); //获取当前滑出的SwipeLayout
interceptStatus = SWIPE_MENU_OPEN; //标记为SwipeLayout滑动
return false;
}
if (currentSwipeLayout != null && currentSwipeLayout.getOpenStatus() != SwipeLayout.Status.Close) { //如果当前有打开或者正在打开的SwipeLayout
Log.d(TAG, "currentSwipeLayout.getOpenStatus() " + currentSwipeLayout.getOpenStatus());
interceptStatus = SWIPE_MENU_CLOSE;//此次用户操作为关闭SwipeLayout
Rect rect = new Rect();
currentSwipeLayout.getHitRect(rect);
//判断当前点击X Y坐标是否在当前SwipeLayout中,即用户是否点击这个SwipeLayout,有就不拦截时间交由SwipeLayout自己处理
if (rect.contains(pressX, pressY)) {
return false;
}
onInterceptTouchEvent中down事件
case MotionEvent.ACTION_DOWN:
//如果没有就关闭并且拦截此时间顺序中所有事件
currentSwipeLayout.close();
return true;
onTouchEvent中的move事件
case MotionEvent.ACTION_MOVE:
if (interceptStatus == SWIPE_MENU_CLOSE)//如果是SwipeLayout关闭事件序列则拦截事件
return true;
//判断当前点击X Y坐标是否在当前SwipeLayout中,即用户是否点击这个SwipeLayout,有就不拦截时间交由SwipeLayout自己处理
if (rect.contains(pressX, pressY)) {
return false;
}
//如果没有就关闭并且拦截此时间顺序中所有事件
currentSwipeLayout.close();
return true;
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有