获取手机屏幕的中心坐标 [英] Get the center coordinates of phone screen

查看:128
本文介绍了获取手机屏幕的中心坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以给我一个例子,说明如何获取当前显示屏幕的中心坐标吗?我希望我的对象始终相对于活动视图的中心坐标。

Can someone give me an example of how to get the center coordinates of the current displayed screen? I would like my objects to always be relative to the center coordinates of the active view.

推荐答案

您可以尝试使用 DisplayMetrics 实现解决方案



You can try with DisplayMetrics to achieve your solution

int mWidth= this.getResources().getDisplayMetrics().widthPixels;
int mHeight= this.getResources().getDisplayMetrics().heightPixels;

这篇关于获取手机屏幕的中心坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆