当前位置: 首页 > wzjs >正文

刷信誉网站怎么做seo排名点击 seo查询

刷信誉网站怎么做,seo排名点击 seo查询,最新新冠肺炎疫情,做自由行的网站好一,概述 本文参考android.view.ScaleGestureDetector,对双指旋转手势做了一层封装,采用了向量计算法简单实现,笔者在此分享下。 二,实例 如下,使用RotateGestureDetector即可委托,实现旋转手…

一,概述

本文参考android.view.ScaleGestureDetector,对双指旋转手势做了一层封装,采用了向量计算法简单实现,笔者在此分享下。

二,实例

如下,使用RotateGestureDetector即可委托,实现旋转手势的简单封装,在对应Callback获取到旋转值设置到View即可。

public class RectView extends FrameLayout {private static final String TAG = "RectView";private View mRotateView;private final ScaleGestureDetector scaleGestureDetector = new ScaleGestureDetector(getContext(), new ScaleGestureDetector.SimpleOnScaleGestureListener() {@Overridepublic boolean onScale(@NonNull ScaleGestureDetector detector) {Log.d(TAG, "onScale() called with: detector = [" + detector.getScaleFactor() + "]");mRotateView.setScaleX(detector.getScaleFactor());mRotateView.setScaleY(detector.getScaleFactor());return true;}@Overridepublic boolean onScaleBegin(@NonNull ScaleGestureDetector detector) {return super.onScaleBegin(detector);}@Overridepublic void onScaleEnd(@NonNull ScaleGestureDetector detector) {super.onScaleEnd(detector);}});private final RotateGestureDetector rotateGestureDetector = new RotateGestureDetector(new RotateGestureDetector.Listener() {@Overridepublic void onRotateStart(RotateGestureDetector detector) {}@Overridepublic void onRotating(RotateGestureDetector detector) {mRotateView.setRotation((float) detector.eulerAngle);}@Overridepublic void onRotateEnd(RotateGestureDetector detector) {}});public RectView(Context context) {super(context);mRotateView = new View(context);mRotateView.setBackgroundColor(Color.GRAY);this.addView(mRotateView, new FrameLayout.LayoutParams(100, 100, Gravity.CENTER));}public RectView(Context context, @Nullable AttributeSet attrs) {super(context, attrs);}public RectView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);}public RectView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {super(context, attrs, defStyleAttr, defStyleRes);}//    @SuppressLint("ClickableViewAccessibility")
//    @Override
//    public boolean onTouchEvent(MotionEvent event) {
//        rotateGestureDetector.onTouchEvent(event);
//        return true;
//    }@Overridepublic boolean dispatchTouchEvent(MotionEvent ev) {rotateGestureDetector.onTouchEvent(ev);scaleGestureDetector.onTouchEvent(ev);return true;}
}

三,实现

Rotate具体实现如下,仅供参考。

import android.view.MotionEvent;import androidx.annotation.NonNull;/*** @author :zhong.jw* @date :Created in 2023/2/23 13:39* 旋转手势相关:采用向量法计算角度*/
public final class RotateGestureDetector {private static final double DEFAULT_LIMIT_START = 3f;@NonNullprivate final Listener listener;/*** 是否旋转中*/public boolean isRotating = false;/*** 旋转轴点x*/public int focusX;/*** 旋转轴点y*/public int focusY;/*** 欧拉角,范围[-180~180]*/public double eulerAngle = 0;/*** 弧度*/public double radian = 0;/*** 开始旋转的初始向量x值*/public double x1 = 0;/*** 开始旋转的初始向量y值*/public double y1 = 0;/*** 开始旋转的初始向量斜率*/public double k1 = 0;public RotateGestureDetector(@NonNull Listener listener) {this.listener = listener;}public boolean onTouchEvent(MotionEvent event) {int action = event.getActionMasked();int pointCount = event.getPointerCount();if ((action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_POINTER_DOWN) && (pointCount == 2) && !isRotating) {double e1x = event.getX(0);double e2x = event.getX(1);double e1y = event.getY(0);double e2y = event.getY(1);focusX = (int) (e1x + e2x) / 2;focusY = (int) ((e1y + e2y) / 2);x1 = e2x - e1x;y1 = e2y - e1y;k1 = y1 / x1;return true;}if (action == MotionEvent.ACTION_MOVE && pointCount == 2) {double e1x = event.getX(0);double e2x = event.getX(1);double e1y = event.getY(0);double e2y = event.getY(1);double x2 = e2x - e1x;double y2 = e2y - e1y;//angle = arccos(ab/(|a||b|))radian = Math.acos((x1 * x2 + y1 * y2) / (Math.sqrt(Math.pow(x1, 2) + Math.pow(y1, 2)) * Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2))));// y = k1*x2 > y2 来判断是否属于外角eulerAngle = (radian / Math.PI * 180) * (k1 * x2 > y2 ? -1 : 1);if (isRotating) {listener.onRotating(this);}if (Math.abs(eulerAngle) >= DEFAULT_LIMIT_START) {isRotating = true;listener.onRotateStart(this);}return true;}if ((action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) && isRotating) {isRotating = false;listener.onRotateEnd(this);}return true;}public interface Listener {/*** @param detector:旋转信息*/void onRotateStart(RotateGestureDetector detector);/*** @param detector:旋转信息*/void onRotating(RotateGestureDetector detector);/*** @param detector:旋转信息*/void onRotateEnd(RotateGestureDetector detector);}}

http://www.dtcms.com/wzjs/110269.html

相关文章:

  • 公司网站建设的分类杭州seo平台
  • 做网站找个人广州百度推广开户
  • 网站的v2信誉认证怎么做网络推广都有哪些平台
  • 我想做个网站怎么弄seo排名赚app官网
  • 浏阳市网站建设上往建站
  • 九江网站网站建设免费推广的预期效果
  • 做门户网站需要具备什么免费web服务器网站
  • 青岛做视频的网站1元涨1000粉
  • 国内高清图片素材网站推荐网络营销策划案怎么写
  • 美国网站做调查赚钱可信吗电脑培训零基础培训班
  • PHP视频类网站应该怎么做yahoo搜索引擎
  • 永嘉县建设局网站站长之家端口扫描
  • 松江网站关键词优化个人免费开发网站
  • 做ppt找图片网站安徽360优化
  • 网站虚拟主机可以做伦理片吗河北网站推广公司
  • 建设企业网站平台主要的目的是谷歌推广怎么做
  • 网站开发考核2345网止导航
  • 做网络销售怎么建立网站镇江市网站
  • dw做的网站怎么让别人看到百度网络营销中心app
  • 怎样用自己的空间做网站优化大师怎么卸载
  • 在微信上做彩票网站武汉网站seo服务
  • 做整装的网站疫情放开死亡人数最新消息
  • 时时彩快3网站开发长沙整合推广
  • 旅游网站建设报价单网站制作工具有哪些
  • 上海市做网站公司2022重大时政热点事件简短
  • 品牌设计网站营销策划经典案例
  • 政府门户网站建设要素全网
  • 辽宁网站建设的网络科技公司网络营销主要做什么
  • 建站工作室品牌营销推广公司
  • 网站建设 平易手机版谷歌浏览器入口