基于android的屏幕尺寸计算图像大小 [英] Calculate image size based on Screen size in android

查看:128
本文介绍了基于android的屏幕尺寸计算图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图来计算图像高度和放大器;宽度根据屏幕大小..我正从后端5'x 7'维图像,以转换72乘以我有360°×504尺寸的图像像素。对于360°×504,我的动态透明的矩形区域将出现在(1.223)×(1.179)即,88.05点¯x84.88。现在对于屏幕尺寸320×480,我想我的计算动态矩形区域的高度和放大器;宽度。对于这个我使用以下的计算:

I am trying to calculate image height & width based on screen size.. I am getting 5'x 7' dimension image from back end , in order to convert pixels multiplying by 72 i have 360 X 504 dimension image. For 360 X 504 , my dynamic transparent rectangular area will appear at (1.223') x (1.179') i.e, 88.05 x 84.88. Now for screen size 320 x 480 i want to calculate my dynamic rectangular area's height & width.. For this i use following calculation :

有关高度:

新的高度=(84.88 / 504)* 480 = 80.83

new height = (84.88/504)*480 = 80.83

,其中84.88 - 矩形图像的高度,504 - 屏幕尺寸,480的高度 - 新屏幕尺寸的高度

where 84.88 - height of rectangular image , 504 - height of screen size , 480 - height of new screen size.

有关宽度相同的:

新宽度=(88.05 / 360)×320 = 78.26

new width= (88.05/360)*320 = 78.26

这是当屏幕尺寸增大或减小?我需要准确地把我的动态影像在主背景图象的矩形区域(棕面积),计算图象大小的方式。

Is this the way to calculate image size when Screen size increases or decreases?I need to place my dynamic image exactly over that Rectangular area (Brownish area)of Main Background image..

请让我知道如果任何进一步的细节需要。

please let me know if any further details needed.

在短:

我将获得的图像 X,Y位置和放大器;高度,宽度为360X504 ..现在我需要计算的 X,Y&安培;高度,宽度小320x480

I will get image x,y position & height,width for 360X504.. Now i need to calculate x,y & height,width for 320x480

推荐答案

如果您可以在$布局p $ P-定义的位置,那么你可能木箱不同的布局按照配置

If you can pre-define the position in the layout, then you can probably crate different layout as per configuration


  • LDPI

  • MDPI


和设置的ImageView scaleType 属性

和以后每当你从服务器获取图像,只需将其设置为视图,它会自动管理缩放包容设备DPI的。

And later whenever you get image from the server, just set it to the View and it will automatically manage the scaling inclusive of the device dpi.

这篇关于基于android的屏幕尺寸计算图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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