1、View的坐标

    /**     * Top position of this view relative to its parent.     *相对应父控件的top位置,单位为像素,即头部到父控件的距离     * @return The top of this view, in pixels.     */    @ViewDebug.CapturedViewProperty    public final int getTop() {        return mTop;    }

其它的getBottom,getLeft,getRight类似

图例:

2、点击View时MotionEvent的坐标

getRawY:表示相对于屏幕左上角的y坐标值(注意:这个屏幕左上角是手机屏幕左上角,不管activity是否有titleBar或是否全屏幕),

getY:表示相对于View自身左上角的y坐标

图例:

组合图:

 

由上图可知:

View到屏幕上边的距离=e.getRawY-.getY

Item到屏幕上边的距离=e.getRawY-e.getY+item.getTop

等等


 

更多相关文章

  1. Android(安卓)8.0 悬浮窗变动与用法
  2. ArcGIS for Android(安卓)如何将经纬度坐标转换成投影坐标
  3. Android(安卓)属性动画实现的扇形菜单效果
  4. 2011.06.17)——— android MotionEvent中getX()和getRawX()的区
  5. Android(安卓)横竖屏幕切换(layout-land和layout-port)
  6. android获取手机屏幕大小
  7. Android中常用的Intent

随机推荐

  1. 12 Android(安卓)AsyncHttpClient 的简单
  2. android WebView使用示例
  3. 关于 getViewTreeObserver
  4. 蓝牙后台长连接 服务
  5. Android(安卓)Retrofit,Gson,Okhttp混淆
  6. 添加轮播图圆点
  7. 【Android】RecyclerView性能优化:setHasF
  8. 【android】Location-based Service
  9. Android(安卓)AlertDialog
  10. 三级缓存图片类