我如何从一个Android设备转换为像素位置(x和y坐标)到其他Android设备? [英] How do I convert a pixel location (x and y coordinates) from one Android device to other Android devices?

查看:133
本文介绍了我如何从一个Android设备转换为像素位置(x和y坐标)到其他Android设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何从一个Android设备转换为像素位置(x和y坐标),以不同的屏幕大小和分辨率不同等Android设备?

How do I convert a pixel location (x and y coordinates) from one Android device to other Android devices with different screen size and different resolution?

推荐答案

一个方法:除法X,Y的屏幕宽度和高度导致从0.0到1.0,然后一个浮点数相乘的2个因素,以第2个设备的屏幕宽度和高度。

One method: Divide x,y by the screen width and height resulting in a float from 0.0 to 1.0 and then multiply those 2 factors to 2nd device's screen width and height.

这篇关于我如何从一个Android设备转换为像素位置(x和y坐标)到其他Android设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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