Android的决议和模拟器不选择正确的图像 [英] Android resolutions and emulator not choosing correct image

查看:97
本文介绍了Android的决议和模拟器不选择正确的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于Android的决议以及它是如何重新psented在模拟器上$ P $一个快速的问题。我已经建立了一个测试项目,测试许多不同的分辨率和他们如何看待每个方向。所以我创建绘制-土地LDPI,MDPI,HDPI-xhpdi,做同样的事情绘端口。我也有所有的布局文件夹,即小M​​ED大型X大,小土地的MED,大片土地,X土地

I have a quick question regarding Android resolutions and how it is represented on the emulator. I have set up a test project to test many different resolutions and how they look on each orientation. So I have created drawable-land-ldpi,mdpi,hdpi-xhpdi and done the same thing for drawable-port. I also have all the layout folders, i.e. small med large x large, small-land,med-land,large-land, x-land

我已经创建了8个测试图像,只是说小港口,土地,媒体端口,土地等等等只是为了检查Android是选择正确的图像。我也创建为每个布局文件夹的布局文件,在布局文件我有一个文本字段刚刚指定的文件夹名称,所以我知道正在使用的布局文件夹。

I have created 8 test images, that just say small port, land, medium port, land etc and so on just to check Android is choosing the correct image. I have also created a layout file for each layout folder, in the layout files I have a text field which just specifies the folder name so I know which layout folder is being used.

我有两个问题,第一个是我在创建每个文件夹的正确的图像大小。我已经为创建的图像尺寸如下

I have two questions, first is am I creating the correct image size for each folder. The image sizes I have created as are follows

绘制-土地LDPI - 320 * 240
绘制端口-LDPI - 240 * 320

drawable-land-ldpi - 320 * 240 drawable-port-ldpi - 240 * 320

绘制-土地MDPI - 480 * 320
绘制端口-MDPI - 320 * 480

drawable-land-mdpi - 480 * 320 drawable-port-mdpi - 320 * 480

绘制-土地华电国际 - 800 * 480
绘制端口,华电国际 - 480 * 800

drawable-land-hdpi - 800 * 480 drawable-port-hdpi - 480 * 800

绘制-土地xhdpi - 1080 * 720
绘制端口-xhdpi - 720×1080

drawable-land-xhdpi - 1080 * 720 drawable-port-xhdpi - 720 * 1080

和我的第二个问题是,为什么这些似乎并没有在模拟器上正确地重新present?举例来说,我已经创建了一个Android应用程序有一个屏幕,并在相应的文件夹中的图像。我创建了两个仿真器,一个是2.3.3,一个是3.0的平板电脑。

And my second question is why do these not seem to represent properly on the emulator? Example, I have created an Android app with one screen and the images in the appropriate folders. I have created two emulators, one is 2.3.3, and one is a 3.0 tablet.

如果我运行它时,它从中等分辨率的文件夹使用图像,并使用媒介布局文件夹我的设备上的设备。因此,如果它是端口它将使用从默认布局文件夹的布局和图像从抽拉口-MDPI并且如果其景观它将使用从默认地夹的布局和图像从可拉伸 - 陆地 - MDPI。

If I run the device on my device which, it uses the image from the medium resolution folder and uses the medium layout folder. So if it is port it will use the layout from the default layout folder and the image from the drawable-port-mdpi and if its landscape it will use the layout from the default land folder and the image from the drawable-land-mdpi.

但是,如果我在模拟器上运行此,在2.3.3设备上,它使用从介质文件夹布局的布局文件夹,但是从绘制-HDPI端口,如果它的风景图像使用介质的景观布局文件夹,但是从可拉伸-HDPI土地的图像。如果我在3.0平板模拟器中运行它,它使用从XLARGE港口和土地XLARGE正确的布局,但它会从绘制,于mdpi文件夹使用图像。

However if I run this on the emulator, on the 2.3.3 device, it uses the layout folder from the medium layout folder, but the image from the drawable-hdpi-port and if its landscape uses the medium landscape layout folder, but the image from the drawable-hdpi-land. If I run it on the 3.0 tablet emulator, it uses the correct layout from the xLarge port and xLarge land, but it uses the image from the drawable-mdpi folders.

我已经在清单中设置支持所有决议和布局。没有任何理由,为什么仿真器这样做呢?我没有在present对我的Andr​​oid平板电脑,以测试这是朋友忘了带,所以我无法测试,如果这在平板电脑上正常工作呢。

I have set up in the manifest to support all resolutions and layouts. Is there any reason why the emulator is doing this? I don't have an Android tablet on me at present to test this as friend forgot to bring it, so I can't test if this works fine on the tablet yet.

我想能够使用模拟器来尝试了一系列的设备测试,但如果没有选择正确的图像,然后我不能依赖它。任何人有这样的问题?还是我做错了什么?

I would like to be able to use the emulator to try out a range of devices to test, but if it is not choosing the correct image then I cannot rely on it. Anyone else have issues like this? Or am I doing something wrong?

任何信息会更AP preciated !!

Any information would be much appreciated!!

推荐答案

像素密度事宜。例如,您的华电国际形象可能是正确的大小,但用不正确的像素密度,它们仍然会得到这些文件夹进行缩放。例如,你的hdpi的图像应具有〜240dpi的像素密度。检查开发者指南支持多种屏幕尺寸:

Pixel density matters. For instance, your hdpi images may be the right size, but with an incorrect pixel density, they will still get scaled in those folders. For instance, your hdpi images should have a pixel density of ~240dpi. Check the developer guide for supporting multiple screen sizes:

http://developer.android.com/guide/practices/screens_support.html

的另一个问题是,该屏幕可以是各种尺寸的,具有不同的像素密度沿,例如,片剂可以是10英寸(X大),但仍然具有中等的像素密度(1280×800)。与此同时,你可以有其他平板电脑也10与xhdpi,如果分辨率是像2560x1600的分辨率。

Another issue is that the screens may be a variety of sizes, along with different pixel densities, e.g., a tablet could be 10 inches (X-Large), but still have a medium pixel density (1280x800). At the same time, you could have another tablet that's also 10" with xhdpi, if the resolution was something like 2560x1600.

这可能是更好地为您基于像素密度注明您的实际布局的文件夹。即,可以使文件夹:

It might be better for you to specify your actual layout folders based on pixel density. i.e., you can make folders:

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 you can still apply port and land to them. Read up on the page about supporting multiple screen sizes, it will probably really help to answer a lot of your questions.

这篇关于Android的决议和模拟器不选择正确的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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