简体   繁体   English

可绘制ldpi / mdpi / hdpi / xhdpi文件夹的最佳位图大小是多少?

[英]What is the optimal bitmap size for drawable ldpi / mdpi / hdpi / xhdpi folders?

I want to scale images such that they fit optimally the screen size and don't consume more memory than required. 我想缩放图像,使其最适合屏幕尺寸,并且不会消耗比要求更多的内存。

Currently I put images made for a 640 x 960 screen in hdpi folder, it looks good, but it consumes a lot more memory than necessary. 目前,我将为640 x 960屏幕制作的图像放在hdpi文件夹中,它看起来不错,但消耗的内存比必要的多得多。 A 480 x 800 device, for example, is hdpi and will load these bitmaps. 例如,一个480 x 800的设备是hdpi,它将加载这些位图。

Since most hdpi devices I know are 480 x 800, my first thought would be to scale down all the images in hdpi to fit a 480 x 800 screen. 由于我所知道的大多数hdpi设备均为480 x 800,因此我的第一个想法是将hdpi中的所有图像缩小以适合480 x 800屏幕。 But I'm not sure, since hdpi doesn't refer to only to resolution, but density. 但我不确定,因为hdpi不仅指分辨率,还指密度。

It's confusing since the folders refer to density, but the bitmaps are just pixels, and I don't know how to assign them there... 由于文件夹指的是密度,所以这很令人困惑,但是位图只是像素,我不知道如何在其中分配它们。

Any help is greatly appreciated. 任何帮助是极大的赞赏。

To give more context: The thing is that I have a bitmap animation with more than 20 bitmaps each 640 x 588 px. 给出更多的上下文:问题是我有一个位图动画,其中有20多个位图,每个640 x 588 px。 So, on some devices this alone will run in out of memory. 因此,仅在某些设备上,这将耗尽内存。 The memory occupied with 640 x 588 is 1.43 mb each bitmap !. 每个位图!占用640 x 588的内存为1.43 mb。 If I scale down to 480 x 441 I get 0.80 mb and that's a huge improvement. 如果我缩小到480 x 441,我得到0.80 mb,这是一个巨大的进步。 And since in a 480 x 800 device I'll not lose detail, I would scale all the tiles down. 而且,由于在480 x 800的设备中我不会丢失细节,因此我会缩小所有图块。

In my opinion, images sized to fit the full screen are just not a good idea for Android in general . 我认为,将图像调整为适合全屏的尺寸通常对于Android来说不是一个好主意 That said, if it's what you need to do, I would worry less about the memory usage and opt for the largest size you think you will need for a particular density, and just let the OS scale down from there for small variances in screen size. 就是说,如果这是您需要做的,那么我就不用担心内存使用问题,而是选择您认为特定密度需要的最大尺寸,然后让OS从那里缩小到较小的屏幕尺寸。 Don't forget you can also specify drawables by screen size as well (eg drawable-large-hdpi ) if you need to get more specific. 别忘了,如果您需要更具体drawable-large-hdpi也可以按屏幕大小指定可绘制对象(例如drawable-large-hdpi )。

Depending on the image, if it's possible to make any part of the background stretchable, I would recommend making it a 9-patch, and sizing it to fit the smallest screen in that density bucket and let it fit to the screen that way. 根据图像,如果可以使背景的任何部分都可拉伸,我建议将其设置为9色块,并调整其大小以适合该密度桶中的最小屏幕,并使其以这种方式适合屏幕。

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

相关问题 'drawable'文件夹和'drawable-hdpi-ldpi-mdpi-xhdpi'文件夹之间有什么区别? - What's differences between 'drawable' folder and 'drawable-hdpi-ldpi-mdpi-xhdpi' folders? 图像大小(drawable-hdpi/ldpi/mdpi/xhdpi) - image size (drawable-hdpi/ldpi/mdpi/xhdpi) 可绘制尺寸:LDPI,MDPI,HDPI,XHDPI,XXHDPI,XXXHDPI? - Sizes for drawable: LDPI, MDPI, HDPI, XHDPI, XXHDPI, XXXHDPI? ldpi、mdpi、hdpi 和 xhdpi 屏幕的背景应该是哪种尺寸? - Which size should a background be for ldpi, mdpi, hdpi and xhdpi screens? 缩放ldpi,mdpi,hdpi和xhdpi的图像 - scale images for ldpi mdpi hdpi and xhdpi ldpi,mdpi,ldpi和xhdpi的图像应为多少像素? - What size in Pixels should my images be for ldpi, mdpi, ldpi, and xhdpi? 如何在 mdpi、ldpi、hdpi、xhdpi 中调整图像大小 - How to resize image in mdpi, ldpi, hdpi, xhdpi 如果为ldpi,mdpi,hdpi,xhdpi提供了可绘制资源,则不需要为nodpi提供可绘制资源吗? - If a drawable resource is provided for ldpi, mdpi, hdpi, xhdpi, this drawable does not need to provided for nodpi? 按照以下描述的设计,xxxhpi,xxhdpi,xhdpi,hdpi,mdpi,ldpi上100px文本的字体大小是多少? - What will be font size of 100px text on xxxhpi, xxhdpi, xhdpi, hdpi, mdpi, ldpi as per below described design? 如何确定加载了哪个位图资源(ldpi,mdpi或hdpi)? - How to determine what bitmap resource was loaded (ldpi, mdpi, or hdpi)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM