android拖动图片移动效果(3)

来源:未知 责任编辑:责任编辑 发表时间:2014-01-20 07:51 点击:

 
                lastX = (int) event.getRawX(); 
                lastY = (int) event.getRawY(); 
 
                break; 
            case MotionEvent.ACTION_UP: 
                break; 
            } 
            return true; 
        } 
    }; 

 
 xml 代码
Java代码 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <RelativeLayout android:id="@+id/relativeLayout1" 
        android:layout_width="fill_parent" android:layout_height="fill_parent"> 
        <ImageView android:id="@+id/imageView1" 
            android:layout_width="wrap_content" android:background="@drawable/icon" 
            android:layout_height="wrap_content" android:layout_alignParentLeft="true"></ImageView> 
        <ImageView android:id="@+id/imageView2" 
            android:layout_width="wrap_content" android:background="@drawable/icon" 
            android:layout_height="wrap_content" android:layout_toRightOf="@+id/imageView1" 
            android:layout_alignTop="@+id/imageView1" android:layout_alignBottom="@+id/imageView1"></ImageView> 
    </RelativeLayout> 
 
</LinearLayout> 
 
 
其中 在onTouch 代码中 如果返回 false 就不能捕捉到ACTION_MOVE 事件。
 对于onTouchEvent 中onTouch返回值
1 、如果return false 说明还没有消费onTouch事件,在执行onTouch里代码后,onTouch事件并没有结束。
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • Android 完全退出程序
  • 原创:Android应用开发-Andorid歌词秀,含源码
  • android 屏幕保护
  • Android手机软件汉化教程---第四课 dex文件汉化
  • 众多Android 开源项目推荐,给力工作给力学习
  • Android Audio代码分析4
  • Android得到已安装的应用程序信息!
  • Android开发者指南(29) —— USB Host and Accessory
  • Android成长的幕后推手:工程师鲁宾
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1