android - 从android中的运动事件获取所有x和y坐标

标签 android drawing coordinates points

我目前正在开发我自己的基本绘图应用程序。到目前为止,我的应用程序运行良好,但我注意到我的运动事件似乎并没有得到所有被触摸的 X 和 Y 轴点。

当我在屏幕上移动手指时,圆圈之间有明显的空隙。只有当我慢慢移动手指时,它才会捕捉到所有的点。有什么办法可以捕获所有的点,或者有什么方法可以优化它以处理所有的点吗?

这是我的做法:

setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(View v, MotionEvent event) {

                int x; 
            int y;    

            switch (event.getAction())
            {
                case MotionEvent.ACTION_DOWN:
                {
                    x = (int) event.getX();
                    y = (int) event.getY();   
                    //method draws circle at x and y coordinate
                    MyPainter mp = new MyPainter(x,y);

                    break;
                }
                case MotionEvent.ACTION_MOVE:
                {
                    x = (int) event.getX();
                    y = (int) event.getY();
                MyPainter mp = new MyPainter(x,y);

                    break;
                }
            }
            return true;

        }
    });

如有任何建议或意见,我们将不胜感激。谢谢

最佳答案

这就是硬件的设计方式。硬件每秒对触摸屏进行 N 次采样,并在每次感应到手指时吐出坐标。

如果您移动的速度比屏幕示例快,那么报告的数据就会有间隙。您唯一能做的就是通过沿着两次触摸之间的线进行插值来自己生成缺失点。

关于android - 从android中的运动事件获取所有x和y坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13547875/

相关文章:

ios - 使用 CoreGraphics 绘制半圆

objective-c - 以编程方式滚动 UIScrollView

php - 使用随机位置方法显示所有位置

android - 在设备上没有互联网连接的情况下启动 Android 应用程序会出现 FileNotFoundException

Android zxing - 人像相机预览/surfaceview 被拉伸(stretch)/扭曲

android - Gigya Android 不会在登录时进入挂起注册回调

android - 如何伪造屏幕分辨率

android - Canvas 的 drawLine 和 drawRect 不包括结束位置?

graphics - Haskell 像素绘图库 Linux

c - 在c中定位数组中的颜色