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

wordpress 企业站模版营销网站建设内容

wordpress 企业站模版,营销网站建设内容,购物网站策划案,雅虎搜索引擎一,概述 本文参考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/814142.html

相关文章:

  • nas服务器 做网站微信公众平台注册不了
  • aspx网站配置服务器深圳最大的手机市场在什么地方
  • 南京网站建设工作室建立网站需要注册公司吗
  • 网站建站那个好网络培训的功能主要有
  • dnf怎么做钓鱼网站网站制作教程一般地建网络
  • 网站应用网站开发百度网站关键字
  • 廊坊企业建站在地税网站怎么做税种认定
  • 中国建设部网站监理延续cn域名注册网站
  • 网站建设公司服怎么做免费的产品图片网站
  • 网站网站做维护wordpress扁平化主题
  • 好看的网站排版专做轮胎的网站
  • 做网站能用自己电脑吗各大网站网址是多少
  • 响应式网站写法编程培训机构排名前十
  • 网站布局结构图海口网站建设电话
  • 我是做化工回收的做哪个网站比较好如何建立自己网站视频
  • 庞各庄网站开发公司wordpress忽略更新
  • 网站推广的方式包括中国设计在线网站
  • 公司实力 网站阿里巴巴网站基础建设首保服务
  • 安全的响应式网站建设外贸网站推广软件
  • 网站建设的开发方式企业网站建设数据现状分析
  • 鄂尔多斯市住房和城乡建设厅网站江北关键词优化排名seo
  • 怎么做卡商网站互联网行业的开发网站
  • 企业网站建设应避免数据孤岛品牌策划公司哪家好
  • 重庆网站建设公司排名直接下载app
  • 网站建设柒金手指花总15wordpress 列表 分类
  • wordpress百度站内搜索什么网站可以做软件有哪些
  • 学校网站 建设 价格海外网深一度
  • app介绍网站模板wordpress和帝国
  • 国网北京电力建设研究院网站鲜花销售网站建设策划表
  • 成都网站建设成都重庆顶呱呱网站建设