如何改变点的位置,每屏分辨率? [英] How to change position of point as per screen resolution?

查看:185
本文介绍了如何改变点的位置,每屏分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假如我把一些点作为(X1,Y1)=(133123),(X2,Y2)=(149136),(X3,Y3)=(182136)等,这使得形状是这样的:

Suppose I put some points as (x1,y1) = (133,123), (x2,y2) = (149,136), (x3,y3) = (182,136) and so on which makes a shape something like this:

现在我想改变这些点的位置,按照屏幕分辨率,这样的形状被调整,并得到集中,也使得形状不被损坏。请帮我。

Now I want to change the position of these points as per the screen resolution such that the shape gets resized and gets centered and also such that the shape doesn't get damaged. Please help me.

推荐答案

您可以抓住从比例因子 DisplayMetrics 作为的 Android的 - 支持多种屏幕文档:

You can grab the scale factor from the DisplayMetrics as shown in the Android - Supporting Multiple Screens documentation:

final float scale = getResources().getDisplayMetrics().density;

乘以你的x和与 y坐标比例和你点屏幕密度无关。

要适应屏幕上的图像(或查看可能),你可以抓住的宽度和的高度您的视图。检查图像的宽度和高度,并计算最大比例因子。

To fit the image on the screen (or View probably), you can grab the width and height of your View. Check the width and height of your image and calculate the maximum scale factor.

联合(乘)两者的比例因子和你的形象应该适合你的视图。

Combine (multiply) both scale factors and your image should fit your View.

这篇关于如何改变点的位置,每屏分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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