import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import java.util.ArrayList;
/**
* 左滑 or 右滑清屏
* @author chenpin
*/
public class ClearScreenLayout extends FrameLayout {
/**手指按下的x轴位置*/
private int mDownX;
/**手指按下的y轴位置*/
private int mDownY;
/**滑动开始时x轴偏移量*/
private int startX;
/**当前x轴偏移量*/
private int translateX;
/**动画结束时x轴偏移量*/
private int endX;
/**是否已清屏*/
private boolean ifCleared;
/**计算滑动速度*/
private VelocityTracker mVelocityTracker;
/**动画*/
private ValueAnimator mAnimator;
/**true-左滑清屏 false-右滑清屏*/
private boolean leftSlide = true;
/**清屏监听器*/
private OnSlideClearListener slideClearListener;
/**需要清除的View*/
private ArrayList<View> listClearViews = new ArrayList<>();
public ClearScreenLayout(Context context) {
this(context, null);
}
public ClearScreenLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ClearScreenLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
直播侧滑清屏
最新推荐文章于 2022-07-19 00:35:50 发布