简体   繁体   English

Android屏幕尺寸资源

[英]Android Screen Size resources

I am trying to understand screen sizes and densities and what I really need to do in order to make my multiple choice question game work on every Android screen nicely. 我试图了解屏幕尺寸和密度以及我真正需要做的事情,以使我的选择题游戏能够在每个Android屏幕上正常运行。 I want my game to look the same in every screen size and density meaning no changes to the layout and good looking images. 我希望我的游戏在每个屏幕尺寸和密度下看起来都一样,这意味着布局和外观都应保持不变。

Basically my game displays questions which are png files, and answers to choose from which are also png files. 基本上,我的游戏显示的问题是png文件,而答案也可以选择png文件。 I specify each imageview size and imagebutton in dp, and the locations of these on the screen in dp. 我在dp中指定每个imageview大小和imagebutton,并在dp中指定它们在屏幕上的位置。 For my layout background image I just have it fill parent width and height. 对于我的布局背景图像,我只填充了父级的宽度和高度。

So my question is why can't I just have one drawable folder with hdpi images? 所以我的问题是为什么我不能只拥有一个带有hdpi图像的可绘制文件夹? Therefore, the images would be scaled appropriately in dp on all screen sizes and located in the same place and look the same on every screen. 因此,图像将在所有屏幕尺寸上以dp进行适当缩放,并位于同一位置,并且在每个屏幕上看起来都相同。 And the images would look good on hdpi screens and smaller ones? 并且图像在hdpi屏幕和较小的屏幕上看起来不错? Also, why can't I just have one layout folder with the same explanation?for your answers! 另外,为什么我不能只有一个布局文件夹具有相同的解释?

You can create the only one folder but the images in that must be .9.png bcoz these images stretched according to the screen. 您只能创建一个文件夹,但是其中的图像必须为.9.png bcoz,这些图像将根据屏幕进行拉伸。 Another way is create the different size images and place them in the hdpi,mdpi,ldpi folders. 另一种方法是创建不同尺寸的图像并将其放置在hdpi,mdpi,ldpi文件夹中。

You can create only one folder for both ressources. 您只能为两个资源创建一个文件夹。 But for image, if you dont want to get uggly stretched image you should create 3 image size with different dpi for each folder. 但是对于图像,如果您不想获得难以拉伸的图像,则应为每个文件夹创建3个具有不同dpi的图像尺寸。 Your picture will be sharper for hight dpi screen and faster for low dpi screen with a picture near the final size. 对于高dpi的屏幕,您的图片将更清晰;对于低dpi的屏幕,您的图片将更接近最终尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM