Android getLocationInWindow()返回空值
来源:互联网 发布:软件开发与软件研发 编辑:程序博客网 时间:2024/06/05 11:10
在activity的onCreate()和onResume(),onAttachedToWindow() 方法里调用View.getLocationInWindow()时,View.getLocationInWindow()返回空值,此时,view没有绑定到window,返回在window里的坐标是没有意义的;
在void dispatchAttachedToWindow(AttachInfo info, int visibility) 方法中 view 才绑定到window,例如activity.onWindowFocusChanged()函数。
备注:
// 获取在当前窗口内的绝对坐标
View.getLocationInWindow()
// 获取在整个屏幕内的绝对坐标,注意这个值是要从屏幕顶端算起,也就是包括了通知栏的高度。
View.getLocationOnScreen()
// 下面一组是获取相对在它父窗口里的坐标。
View.getLeft() , View.getTop(), View.getBottom(), View.getRight()
View.getLocationInWindow()和 View.getLocationOnScreen()在window占据全部screen时,返回值相同,不同的典型情况是在Dialog中时。当Dialog出现在屏幕中间时,View.getLocationOnScreen()取得的值要比View.getLocationInWindow()取得的值要大。
参考:
android getLocationInWindow()的小秘密()
- Android getLocationInWindow()返回空值
- Android getLocationInWindow
- android DES解密返回空值
- Android中getLocationOnScreen和getLocationInWindow
- android getLocationInWindow()的小秘密
- Android中getLocationOnScreen和getLocationInWindow
- getLocationInWindow getLocationOnScreen 获取Android坐标
- Android使用ANativeWindow_fromSurface返回空
- android 手机调用java webService返回空值的问题
- android 网络请求图片,返回值为空的解决办法
- android中getLocationInWindow 和 getLocationOnScreen的区别
- android中getLocationInWindow 和 getLocationOnScreen的区别
- android中getLocationInWindow 和 getLocationOnScreen的区别
- android中getLocationInWindow 和 getLocationOnScreen的区别
- android中getLocationInWindow和getLocationOnScreen的区别
- android中getLocationInWindow 和 getLocationOnScreen的区别
- findViewById 返回值为空
- DWR:返回值为空?
- python语言中关于素数的问题
- 北大 AI 公开课第6讲:王俊——DNA是生命数字化的过程,AI改变生命科学
- 深入解析MySQL分区(Partition)功能
- plus-one
- Cocos2d-x v3.X的颜色混合BlendFunc使用详解
- Android getLocationInWindow()返回空值
- 编写 shell脚本
- 修改maven的镜像仓库,提高下载jar包的速度
- GDOI2017模拟Round4总结
- python——模块
- 怎么做bug预防?
- REST风格概述
- MySQL数据库
- python-opencv旋转图像,保持图像不被裁减