简体   繁体   English

Android drawable:不同的密度或比例

[英]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.

相关问题 在Android上重复使用不同屏幕尺寸和密度的可绘制图像 - Reuse drawable images for different screen sizes and densities on Android 不同密度的Android值 - Android values for different densities 适用于不同密度的Android资源 - Android resources for different densities 如何在android studio 3.5中以不同的密度在drawable文件夹中添加jpg文件? - How to add jpg files in drawable folder with different densities in android studio 3.5? 9-Patch可绘制尺寸Android。 不同密度如何处理未拉伸区域? - 9-Patch drawable dimensions Android. How do different densities handle the non-stretched areas? 如何将不同像素密度的相同图像添加到drawable目录(android studio)? - How do you add the same images of different pixel densities to the drawable directory (android studio)? 不同Android设备的密度列表 - List of densities for different android devices Android 的不同屏幕密度的文件夹 - Folders for different screen densities for Android 如何在Android中的不同屏幕密度下使位图中的文本正确缩放? - How do I make text in a Bitmap scale properly on different screen densities in Android? 如何在Android Studio中缩放可绘制为不同屏幕尺寸的自定义按钮? - How to scale a custom button drawable for different screen sizes in android studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM