Android的维护所有不同的屏幕尺寸和分辨率相同的比例 [英] Android maintain same proportion for all different screen sizes and resolution

查看:288
本文介绍了Android的维护所有不同的屏幕尺寸和分辨率相同的比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的应用程序组件在缩放机制的样子。意味着图像的大小必须寻找与屏幕尺寸比例。

I want my application components to look in a scaling mechanism. Means image size must look in proportion with screen size.

我知道,使用4个不同的绘制文件夹。

I know that to use 4 different drawable folders.

考虑到华电国际为基础(480×800)的比例将是:

Considering hdpi as base (480 x 800) ratio would be:

于mdpi 66.66%
华电国际100%
xhdpi 133.33%

mdpi 66.66% hdpi 100% xhdpi 133.33%

不过xhdpi大小accoring上面比为640×1060。
但三星S3的屏幕尺寸为720×1280

however xhdpi size accoring to above ration is 640 x 1060. But samsung s3 screen size is 720 x 1280

因此​​,假设如果我有100在华电国际×100的图像,所以133 X 133在xhdpi

So suppose If I have image of 100 x 100 in hdpi, and so 133 x 133 in xhdpi

但应用上述规则后,图像尺寸是基于xhdpi(133 X 133)图像三星S3不寻求与屏幕大小相称。

But after applying above rule, Image in samsung s3 not looking proportionality with screen size as image size is based on xhdpi (133 x 133).

在480 * 854的屏幕尺寸华电国际同样的问题。假设我有在屏幕上显示的图像,如何填补这54像素的差距呢?作为我们的形象在华电国际文件基础上480 x 800的。

Same problem in hdpi with 480 x 854 screen size. Suppose I have to display images on screen, how to filled up that 54 px gap? as our images are based on 480 x 800 in hdpi folder .

所以我的问题是我们如何能够得到更小的屏幕尺寸和更大的图像较小的图像更大的屏幕尺寸,使所有的布局和图像看起来与比例屏幕尺寸?

So my question is how can we get smaller image for smaller screen size and bigger image for bigger screen size so that all layout and images looks in proportional with screen size?

推荐答案

如果你甚至不与屏幕上的像素越少妥协那么这将是您的理想选择使用

If you do not compromise not even with a fewer pixels on the screen then it would be ideal for you to use

layout-sw720dp folder for Samsung S3

更多信息以href=\"http://developer.android.com/guide/practices/screens_support.html\" rel=\"nofollow\">

下面将要使用的一些典型的屏幕宽度

below are some typical screen widths to be used

res/layout/main_activity.xml # For handsets (smaller than 600dp available width)
res/layout-sw600dp/main_activity.xml # For 7" tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml # For 10" tablets (720dp wide and bigger)

和让你的文件夹,绘制如下图所示。

and make your drawable folder like below

xhdpi: 720x1280

large-hdpi: 640x960

hdpi: 480x640

mdpi: 320x480

ldpi: 240x320

这篇关于Android的维护所有不同的屏幕尺寸和分辨率相同的比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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