仿抖音短视频源码,高仿抖音双击点赞效果之双击的问题

仿抖音短视频源码中,实现仿抖音的双击点赞效果,相关代码如下:

public class MyView extends View {
     
    private GestureDetector gestureDetector;
    private boolean background = false;

    public MyView(Context context) {
     
        this(context, null);
    }

    public MyView(Context context, AttributeSet attrs) {
     
        super(context, attrs);
        gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
     
            @Override
            public boolean onDoubleTap(MotionEvent e) {
     
                if (background)
                    setBackgroundColor(0xffff00ff);
                else setBackgroundColor(0xFF001AFF);
                background = !background;
                return super.onDoubleTap(e);
            }
        });
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
     
        gestureDetector.onTouchEvent(event);
        return true;
    }
}
 

以上就是仿抖音短视频源码中,高仿抖音双击点赞效果的相关代码,更多信息欢迎关注之后的文章
本文转载自网络,转载仅为分享干货知识,如有侵权欢迎联系云豹科技进行删除处理

你可能感兴趣的:(技术类,java,android,css,编程语言,人工智能)