简体   繁体   English

所有屏幕的背景图像大小

[英]Background image size for all screens

I want to use background image in my app.But i am so confused about different screen sizes.I found this question: 我想在我的应用程序中使用背景图片,但是我对不同的屏幕尺寸感到困惑。我发现了这个问题:

Android: Background Image Size (in Pixel) which Support All Devices Android:支持所有设备的背景图片大小(以像素为单位)

But in answer he said xxxhdpi: 1280x1920 px but Lg G3 is xxxHdpi and screen resolution: 1440 x 2560 但在回答中,他说xxxhdpi: 1280x1920 px但Lg G3是xxxHdpi和屏幕分辨率: 1440 x 2560

I need a roadmap.How should be my image sizes for all screens ? 我需要一个路线图,所有屏幕的图像尺寸应该如何? (mdpi,hdpi,xhdpi etc.) (mdpi,hdpi,xhdpi等)

Android devices' screen sizes in pixels and screen width in inches, can differ significantly from device to device. Android设备的屏幕尺寸(以像素为单位)和屏幕宽度(以英寸为单位)可能因设备而异。 To address this issue, google lets you use different resources per size/density category See here for some more info. 为解决此问题,Google允许您针对每个尺寸/密度类别使用不同的资源。有关更多信息,请参见此处

Generally speaking, you must put the largest size image that you want to support for each dpi in the correct folder, and let android do the resizing. 一般来说,您必须将要支持的每个dpi的最大尺寸的图像放在正确的文件夹中,然后让android进行大小调整。

You can also check the imageView's ScaleType attribute to choose how to scale the image to fit the view. 您还可以检查imageView的ScaleType属性以选择如何缩放图像以适合视图。

EDIT 编辑

the reason to use the different folders and not just one large image is that the larger the image, the more memory it consumes. 使用不同文件夹而不仅仅是一张大图像的原因是,图像越大,消耗的内存就越多。 For example a 1920x1280 image is nice to have on a 1920 screen, but on a 320pixels screen the extra resolution is wasted and you have a lot of wasted memory used. 例如,在1920屏幕上拥有1920x1280的图像是不错的选择,但是在320像素的屏幕上,多余的分辨率就被浪费掉了,并且您浪费了很多内存。

An easier way is to include one single image in your drawable directory, then, in the OnCreate function of your activity, create a bitmap to fit the screen and put it in an imageview that has width and height set to "wrap_content". 一种更简单的方法是在可绘制目录中包含一个图像,然后在活动的OnCreate函数中创建一个位图以适合屏幕,并将其放入宽度和高度设置为“ wrap_content”的图像视图中。

This should work for any device. 这适用于任何设备。

Read this link . 阅读此链接 In particular, I think what you're looking for is: 特别是,我认为您正在寻找的是:

To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8:12:16 scaling ratio between the six generalized densities. 若要为不同的密度创建替代的位图可绘制对象,应遵循六个广义密度之间的3:4:6:8:12:16缩放比例。 For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screens, all the different sizes should be: 例如,如果对于中等密度的屏幕,您有一个48x48像素的可绘制位图,则所有不同的大小应为:

36x36 (0.75x) for low-density 36x36(0.75x)用于低密度

48x48 (1.0x baseline) for medium-density 48x48(1.0x基准),中等密度

72x72 (1.5x) for high-density 72x72(1.5x)用于高密度

96x96 (2.0x) for extra-high-density 96x96(2.0x)用于超高密度

180x180 (3.0x) for extra-extra-high-density 180x180(3.0x)用于超高密度

192x192 (4.0x) for extra-extra-extra-high-density 192x192(4.0x)用于超高密度

and also: 并且:

xlarge screens are at least 960dp x 720dp xlarge屏幕至少为960dp x 720dp

large screens are at least 640dp x 480dp 大屏幕至少为640dp x 480dp

normal screens are at least 470dp x 320dp 普通屏幕至少为470dp x 320dp

small screens are at least 426dp x 320dp 小萤幕至少为426dp x 320dp

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

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