Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问我把onTouch相关的内容,写在自己集成的zxing的carputureActivity里,事件不触发,请问如果要实现缩放该添加哪些内容呢?新人,求大佬指教! #24

Closed
bubble96 opened this issue Jan 10, 2019 · 5 comments

Comments

@bubble96
Copy link

是每次onTouch 一定要在camera.open一遍吗?可是我打断点,这个时间都没触发

@bubble96
Copy link
Author

@jenly1314大大有空吗?

@jenly1314
Copy link
Owner

不需要。不太清楚你代码怎么写的。

  1. 实现缩放需了解其原理就比较容易去实现,缩放的本质都是通过事件触发变焦
    camera.getParameters().setZoom(int zoom); 达到想要达到效果。
  2. 源生zxing并不好用,用户体验很不好,所以才会出现各种基于zxing的衍生库。

@bubble96
Copy link
Author

嗯,项目需要,现集成的是QRcode的库,需求要求加上手指缩放,我一开始想的是在CaputureActivity重写onTouchEvent,然后在判定双指的时候,进行缩放,但是断点显示事件没触发,所以一直不知道该怎么去修改,望大大指点,可以贴出代码

@jenly1314
Copy link
Owner

jenly1314 commented Jan 11, 2019

onTouchEvent中的主要逻辑如下:

 switch (event.getAction() & MotionEvent.ACTION_MASK) {//TODO: 多点触控
            case MotionEvent.ACTION_POINTER_DOWN:
                //TODO: 多点触摸按下时事件。此处记录手指按下时初始距离逻辑

                break;
            case MotionEvent.ACTION_MOVE:
                //TODO: 移动时事件。计算出移动时手指距离与上一次移动时手指距离进行对比(初次移动的上一次距离为手指按下时初始距离),如果移动距离远了则放大变焦,反之则缩小变焦。

                break;
        }

具体示例可参见:CaptureActivity中的onTouchEvent方法。

@bubble96
Copy link
Author

谢谢大大解答,我重写的onTouchEvent事件是差不多的,现在困扰我的是这个事件没有触发,然后我一直找不到原因,但是看大大写的就能触发,所以在想是代码哪里不一样,还是我欠缺哪个地方没写,所以重写的事件无法被触发

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants