[英]Android drawable: different densities or scale
I have designed an in-app keypad for my Android application and I need to provide an image for every key. 我已经为Android应用程序设计了一个应用程序内键盘,并且需要为每个按键提供一个图像。 Currently I've only loaded one large image for each one that is being scaled down to adjust to the layout. 目前,我只为缩小比例以适应布局的每幅图像加载一张大图像。 Also, this looks nice in every resolution. 另外,在每种分辨率下看起来都不错。
Is this approach acceptable or should I provide different images for different screen densities? 这种方法是否可以接受,或者我应该针对不同的屏幕密度提供不同的图像? Currently I've placed those inside the generic drawable directory. 目前,我已经将它们放置在通用的drawable目录中。
You should. 你应该。 Some mobiles with lower resolution, usually won't have much memory. 某些分辨率较低的手机通常没有太多内存。 Loading large images in small screen takes too much memory, which might end up crashing. 在小屏幕上加载大图像会占用太多内存,最终可能会导致崩溃。 So if you give different images, then according to density it will take appropriate images. 因此,如果您提供不同的图像,则根据浓度它将拍摄适当的图像。 check this out. 检查这出。
It's acceptable in some cases but certainly not optimal. 在某些情况下可以接受,但肯定不是最佳选择。
For best memory performance and the least amount of artifacts I would still recommend to provide alternative bitmap resources for different densities, like the Android documentation recommends. 为了获得最佳的内存性能和最少的工件,我仍然建议像Android文档所建议的那样为不同的密度提供替代的位图资源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.