本文主要是介绍低灵敏度SwipeRefreshLayout,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
低灵敏度SwipeRefreshLayout
package com.ss.android.homed.pm_home.decorate.view;import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.AttributeSet;
import android.view.MotionEvent;/*** 低灵敏度SwipeRefreshLayout*/
public class MySwipeRefreshLayout extends SwipeRefreshLayout {private float mInitialDownY;private int mTouchSlop = 300;public MySwipeRefreshLayout(Context context) {this(context, null);}public MySwipeRefreshLayout(Context context, AttributeSet attrs) {super(context, attrs);}@Overridepublic boolean onInterceptTouchEvent(MotionEvent ev) {final int action = ev.getAction();switch (action) {case MotionEvent.ACTION_DOWN:mInitialDownY = ev.getY();break;case MotionEvent.ACTION_MOVE:final float yDiff = ev.getY() - mInitialDownY;if (yDiff < mTouchSlop) {return false;}}return super.onInterceptTouchEvent(ev);}/*** @return 返回灵敏度数值*/public int getTouchSlop() {return mTouchSlop;}/*** 设置下拉灵敏度** @param mTouchSlop dip值*/public void setTouchSlop(int mTouchSlop) {this.mTouchSlop = mTouchSlop;}}
这篇关于低灵敏度SwipeRefreshLayout的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!