且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何移动手指触摸图片中的android?

更新时间:2023-02-26 22:23:01

见的如何做这种的博客文章。你需要看看 SurfaceView 和的 onTouchListener 。从博客摘自:

See this blog post on how to do it. You need to look at SurfaceView and the onTouchListener. Taken from the blog:

              surf.setOnTouchListener( new SurfaceView.OnTouchListener(){
                  public boolean onTouch(View v, MotionEvent event) {
                     case MotionEvent.ACTION_MOVE:
                        if( moving ){
                            final int x_new = (int)event.getX();
                            final int y_new = (int)event.getY();
                            mDrawTiles.draw( new DrawLogic(){
                                @Override
                                public void draw(Rect _surface) {
                                    mTiles.setBounds(
                                        x_new - mDrawWidth/2,
                                        y_new - mDrawHeight/2,
                                        x_new + mDrawWidth/2,
                                        y_new + mDrawHeight/2);
                                    }
                                });
                            }