gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 16:30:24 25 4
gpt4 key购买 nike

我知道如果 Android 在所需的文件夹中找不到图标,它会尽力而为,但我看到有些地方他们建议上述所有内容,而在其他地方他们不包括 drawable ?

那么,如果所有其他的都充满了我的标签图标图像,我是否也应该填充可绘制对象?

最佳答案

如果您使用 VectorDrawable ,您不需要为每个密度(mdpi、xhdpi 等)添加资源。 VectorDrawable自 API 21 (Lollipop) 或支持库(或 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.

另一方面,对于图像 (PNG),您必须为每个密度添加适当的图标,因为 Android 会尝试缩放图像(因此它们可以在所有设备中按比例占据相同的区域)。缩放时,图像可能会变得模糊,从而降低 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.

您可以阅读更多HEREHERE

编辑

也许,您不需要复制ALL 图标。许多因素会导致不同的体验,例如使用 wrap_content或特定尺寸来控制图标大小,甚至使用不同的 scaleType在你的ImageView .所以,也许,您可以先为 xhdpi 添加图标或 xxhdpi仅文件夹并在不同屏幕(小显示器、大显示器、低分辨率显示器、高分辨率显示器等)中检查您的屏幕。然后,您可以只“复制”必要的图标...但是如果您的项目或 APK 大小相对较小,请不要介意复制图标。

甚至有一些在线工具可以从单个 PNG 生成每个密度的 Assets ,例如 Android Asset Studio网站..

关于android - 我是否需要使用所有 drawable、drawable-mdpi、drawable-hdpi、drawable-xhdpi、drawable-xxhdpi 和 drawable-xxxhdpi?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56563463/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com