android 获取屏幕宽高 和 获取控件坐标
一.获取屏幕宽高:
WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
int width = wm.getDefaultDisplay().getWidth();
int height = wm.getDefaultDisplay().getHeight();
(2).
WindowManager wm = this.getWindowManager();
int width = wm.getDefaultDisplay().getWidth();
int height = wm.getDefaultDisplay().getHeight();
二.获取控件的坐标:
int[] location = new int[2];
t.getLocationOnScreen(location);
int x = location[0];
int y = location[1];
System.out.println("x:"+x+"y:"+y);
System.out.println("图片各个角Left:"+t.getLeft()+"Right:"+t.getRight()+"Top:"+t.getTop()+"Bottom:"+t.getBottom());
android 获取屏幕宽高 和 获取控件坐标的更多相关文章
- android获取屏幕宽高与获取控件宽高
获取屏幕宽高 // 获取屏幕宽高(方法1) int screenWidth = getWindowManager().getDefaultDisplay().getWidth(); // 屏幕宽(像素 ...
- vue 获取屏幕宽高 width height
/** * 获取屏幕宽高 */ Vue.prototype.getViewportSize = function(){ return { width: window.innerWidt ...
- Flutter获取屏幕宽高和Widget大小
我们平时在开发中的过程中通常都会获取屏幕或者 widget 的宽高用来做一些事情,在 Flutter 中,我们可以使用如下方法来获取屏幕或者 widget 的宽高. MediaQuery 一般情况下, ...
- js获取屏幕宽高
最近想自己实现一个全屏滚动. 结果一开始就遇到了问题.因为不知道如何获取一个页面屏幕的高度. 网上所有的博客都是复制粘贴. 网页可见区域宽:document.body.clientWidth 网页可见 ...
- js、jq获取屏幕宽高
参考资料 JS,Jquery获取各种屏幕的宽度和高度
- 【Html】网页获取屏幕宽高
<html> <script> function size(){ document.write( "屏幕分辨率为:"+screen.width+" ...
- js 获取屏幕宽高
网页可见区域宽: document.body.clientWidth 网页可见区域高: document.body.clientHeight 网页可见区域宽: document.body.offset ...
- Swift 获取屏幕宽高
let screenh = UIScreen.mainScreen().applicationFrame.size.heightlet screenw = UIScreen.mainScreen(). ...
- Javascript之获取屏幕宽高
<head> <title> new document </title> <meta name="generator" content=& ...
随机推荐
- 关于Linux上的SSH服务无法启动,提示“/var/empty/sshd must be owned by root and not group or world-writable”错误
首先通过物理终端进入到linux上,手工检查ssh发现没运行# /etc/init.d/sshd statussshd is stopped 手动启动服务,发现报告权限错误.# /etc/init.d ...
- mysql 导入数据库
1:创建数据库 dos 进入 xxx\MySQL5.7\bin 目录(很多人喜欢把这个路径配置在环境变量path中,这样在dos敲命令时,就直接是mysql......) mysql -uroot - ...
- 【cpu】CPU版本认识
此图应该是摘选自<鸟哥的linux私房菜>
- 【curl】【php】curl报错,错误代码77,CURLE_SSL_CACERT_BADFILE (77)解决方法
CURLE_SSL_CACERT_BADFILE (77) - 读取 SSL CA 证书时遇到问题(可能是路径错误或访问权限问题) 在微信接口相关开发时容易出现此问题 这一般是因为服务更新了相关的软件 ...
- timer event
/* linux/kernel/time/jiffies.c*/ static cycle_t jiffies_read(struct clocksource *cs) { return (cycle ...
- scheduleWithFixedDelay和scheduleAtFixedRate源码分析
先放张图,有兴趣的话我再加细节说明. scheduleWithFixedDelay和scheduleAtFixedRate的执行流程都是一样的,如下 ScheduledThreadPoolExecut ...
- 【Oracle】使用dblink+minus方式迁移数据
一.需求说明 1.数据库a104的表syssde.a4_syssde_department中有1000条数据: 2.数据库a230的表syssde.a4_syssde_department中有800条 ...
- luogu3396 哈希冲突
参考这里 我们先预处理模数在 \(\sqrt{n}\) 以内的询问. 要是模数在 \(\sqrt{n}\) 以外,直接暴力统计,反正这样的数又不会超过 \(\sqrt{n}\) 个. 修改的时候也是. ...
- Appium启动app
首先要获取包名,然后获取launcherActivity.获取这两个关键东西的方法很多,这里就不一一多说,小伙伴们可以各显神通.小编这里主要给大家推荐一个sdk自带的实用工具aapt. aapt即An ...
- tensorflow 如何限制显存大小
Python在用GPU跑模型的时候最好开多进程,因为很明显这种任务就是计算密集型的. 用进程池好管理,但是tensorflow默认情况会最大占用显存,尽管该任务并不需要这么多,因此我们可以设置显存的按 ...