android手机坐标系之getLocationOnScreengetLocationInWindow等总结
简书链接:android手机坐标系之getLocationOnScreengetLocationInWindow等总结
文章字数:491,阅读全文大约需要1分钟
1 | int[] locationScreen = new int[2]; |
区别:在activity测试暂时没发现区别,如果弹出一个对话框获取对话框的view的话,那么窗口的y x大小肯定小于屏幕大小了。
1 | ```view.getTranslateX()```表示相对于原来自身偏移了多少,默认是0 ,如果往右边偏移数值越大,如果往左偏移y就是负数,如果往上偏移就是y负数 |
btnTousch:action:1,ranx410.54382,ranY:794.4483,x:48.543823
1 |
view,所在位置:top:591,bottom:687,left362,width:176,362.0,y:591.0,屏幕x:362,,屏幕y:753,窗口x:362,窗口y:753
1 | 模拟点击模拟的是```getRaw``` |
源码得知getRawX就是获取屏幕到view的坐标位置
Returns the original raw X coordinate of this event. For touch
* events on the screen, this is the original location of the event
* on the screen, before it had been adjusted for the containing window
* and views.
### 其他
```getLeft() ```等等就是获取view距离父view的距离了.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 情迁博客!
评论