如何移动手指触摸图片中的android? [英] how to move images on finger touch in android?

查看:88
本文介绍了如何移动手指触摸图片中的android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Android的一个小应用程序。在此之前,我做了冲浪在互联网上,但我无法得到有用的材料。在此应用中,我有两个选项卡我已经做了这两个选项卡,但我想点击第一个选项卡后,我想一些图像,这些图像可以在右侧移动时,在右侧和左侧的用户触摸它时,它留给用户的触摸是指用户可以上滑动,两个左和右通过手指的图像。任何人都可以建议我任何教程或源$ C ​​$ C,这样我可以做到的功能是这样的。

I am developing an small application in a android. Before this i had done surfing on internet but i can't get useful material. In this application i have two tabs I had made the these two tabs but I want after click on first tab i want some images these Images can move on right side when user touch it on right and left side when user touch it left means user can slide the images on both left and right by finger. Can anyone suggest me any tutorial or source code so that i can able to do functionality like this.

在此先感谢

推荐答案

见的如何做这种的博客文章。你需要看看 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);
                                    }
                                });
                            }

这篇关于如何移动手指触摸图片中的android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆