简体   繁体   English

我是否需要使用所有drawable,drawable-mdpi,drawable-hdpi,drawable-xhdpi,drawable-xxhdpi和drawable-xxxhdpi?

[英]Do I need to use all of drawable, drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi & drawable-xxxhdpi?

I realise that Android will try it's best if it does not find an icon in the required folder but I see someplaces they suggest all of the above and in others they don't include drawable ? 我意识到如果Android没有在所需的文件夹中找到一个图标,Android会尝试它是最好的但是我看到他们建议以上所有的地方,而在其他地方他们不包括drawable

So should I populate drawable as well if all the others are filled with my tab icon images? 如果所有其他人都填充了我的标签图标图像,那么我应该填充drawable吗?

If you use a VectorDrawable , you don't need to add a Resource for every density (mdpi, xhdpi etc). 如果使用VectorDrawable ,则无需为每个密度添加资源(mdpi,xhdpi等)。 VectorDrawable is supported since API 21 (Lollipop) or with Support Library (or AndroidX). VectorDrawable因为API 21(棒棒堂)或支持库(或AndroidX)的支持。

For simple types of images (usually icons), you can avoid creating separate images for each density by using vector graphics. 对于简单类型的图像(通常是图标),您可以避免使用矢量图形为每个密度创建单独的图像。 Because vector graphics define the illustration with geometric line paths instead of pixels, they can be drawn at any size without scaling artifacts. 因为矢量图形使用几何线路径而不是像素来定义插图,所以可以在任何尺寸下绘制它们而不缩放工件。

For images (PNG) on the other hand, you must add proper icons for every density because Android will try to scale the images (so they can proportionally occupy same area in all devices). 另一方面,对于图像(PNG),您必须为每个密度添加适当的图标,因为Android会尝试缩放图像(因此它们可以按比例占据所有设备中的相同区域)。 When scaling, the image may become blurred reducing the quality of your UI. 缩放时,图像可能会变得模糊,从而降低UI的质量。

To provide good graphical qualities on devices with different pixel densities, you should provide multiple versions of each bitmap in your app—one for each density bucket, at a corresponding resolution. 要在具有不同像素密度的设备上提供良好的图形质量,您应该在应用程序中为每个密度桶提供多个版本的每个位图,并以相应的分辨率。 Otherwise, Android must scale your bitmap so it occupies the same visible space on each screen, resulting in scaling artifacts such as blurring. 否则,Android必须缩放您的位图,使其在每个屏幕上占据相同的可见空间,从而导致缩放伪像,例如模糊。

You can read more HERE and HERE 你可以阅读更多这里这里

EDIT 编辑

Maybe, you don't need to duplicate ALL icons. 也许,您不需要复制所有图标。 A lot of factors can lead to different experiences such as using wrap_content or a specific dimension to control the icon size or even using a different scaleType in your ImageView . 许多因素都可能导致不同的体验,例如使用wrap_content或特定维度来控制图标大小,甚至在ImageView使用不同的scaleType So, maybe, you can start by adding icons for xhdpi or xxhdpi folders only and check your screen in different screen (small display, large displays, low-resolution displays, high-resolution displays etc). 因此,也许,您可以首先添加xhdpixxhdpi文件夹的图标, xhdpi在不同的屏幕(小显示屏,大显示屏,低分辨率显示屏,高分辨率显示屏等)中检查您的屏幕。 Then, you can "duplicate" only the necessary icons... But if your project or APK size is relatively small, don't mind to duplicate the icons. 然后,您只能“复制”必要的图标......但如果您的项目或APK大小相对较小,请不要介意复制图标。

There's even some online tools to generate the assets for every density from a single PNG such Android Asset Studio website.. 甚至还有一些在线工具可以从单个PNG(例如Android Asset Studio网站)为每个密度生成资产。

If you are adding all resolution drawable icon like : 如果要添加所有分辨率可绘图标,例如:

drawable-mdpi
drawable-hdpi
drawable-xhdpi
drawable-xxhdpi
drawable-xxxdpi

then you need not to add any extra icons on drawable folder because all the device resolution covers under the above drawable folders 那么你不需要在drawable文件夹上添加任何额外的图标,因为所有设备分辨率都包含在上面的drawable文件夹下

暂无
暂无

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

相关问题 其中drawable-hdpi,drawable-mdpi,drawable-xhdpi和drawable-xxhdpi。 走? - where drawable-hdpi ,drawable-mdpi ,drawable-xhdpi and drawable-xxhdpi. go? Drawable-hdpi,Drawable-mdpi,Drawable-ldpi Android - Drawable-hdpi, Drawable-mdpi, Drawable-ldpi Android Android:Drawable-hdpi,Drawable-mdpi,Drawable-ldpi? - Android : Drawable-hdpi, Drawable-mdpi, Drawable-ldpi? 我对drawable-hdpi和drawable-mdpi很困惑 - I am confused with drawable-hdpi and drawable-mdpi 可绘制尺寸:LDPI,MDPI,HDPI,XHDPI,XXHDPI,XXXHDPI? - Sizes for drawable: LDPI, MDPI, HDPI, XHDPI, XXHDPI, XXXHDPI? 如果已经有drawable,我们是否还需要Android资源中的drawable文件夹 - hpi,mdpi,xhdpi,xxhdpi,xxxhdpi - Do we still need drawable folder in Android Resources if already have drawable - hpi, mdpi, xhdpi,xxhdpi, xxxhdpi 如何使用res文件夹的drawable-hdpi,drawable-mdpi,drawable-ldpi中存在的图像? - how to use images present in drawable-hdpi,drawable-mdpi,drawable-ldpi of res folder? 解释drawable,drawable-ldpi,drawable-mdpi和drawable-hdpi之间的区别 - Explain the difference between drawable, drawable-ldpi, drawable-mdpi and drawable-hdpi DRAWABLE-V21 中的 Android drawble-xhdpi、drawable-xxhdpi、drawable-xxxhdpi 子文件夹也适用于 DRAWABLE-V23? - Android drawble-xhdpi, drawable-xxhdpi, drawable-xxxhdpi subfolders inside DRAWABLE-V21 also for DRAWABLE-V23? drawable-sw720dp与drawable-hdpi,drawable-xhdpi等 - drawable-sw720dp vs drawable-hdpi, drawable-xhdpi and others
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM