纹理映射可绘制的图标 [英] mipmap drawables for icons

查看:229
本文介绍了纹理映射可绘制的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于Android 4.3,我们现在可以使用 RES /纹理映射文件夹来存储的mipmap的图像。

Since Android 4.3 we can now make use of the res/mipmap folders to store "mipmap" images.

例如。 Chrome浏览器Android版的存储其图标,这些文件夹中,而不是更为正常的 RES /绘制文件夹。

e.g. Chrome for Android stores its icons in these folders instead of the more normal res/drawable folders.

如何为这些纹理映射图像从其他熟悉的绘制图像不同?

我看到,在我的清单中,我们用它代替 @drawable / @mipmap / 预选赛,这是有道理的给定资源文件夹名称:

I see that in my manifest, we use the @mipmap/ qualifier, instead of @drawable/, which makes sense given the resource folder name:

<activity
    android:name=".MipmapDemp"
    android:icon="@mipmap/ic_launcher" />


的参考文献:

href="https://developer.android.com/about/versions/android-4.3.html">的Andr​​oid 4.3的API 文档具有


References:

The Android 4.3 APIs document has the following to say:

使用纹理映射为源位图或绘制一个简单的   方式提供了优质的图像和各种图像秤,其可以是   如果你希望你的图像中的缩放特别有用   动画。

Using a mipmap as the source for your bitmap or drawable is a simple way to provide a quality image and various image scales, which can be particularly useful if you expect your image to be scaled during an animation.

的Andr​​oid 4.2(API等级17),增加了支持的位图贴图   类的Andr​​oid交换的MIP图像的位图,当你提供   一个纹理映射源和已启用setHasMipMap()。现在的Andr​​oid 4.3,   您可以启用贴图为BitmapDrawable对象,以及通过   提供的mipmap资产并设置了android:MIPMAP的属性   位图资源文件,或致电hasMipMap()。

Android 4.2 (API level 17) added support for mipmaps in the Bitmap class—Android swaps the mip images in your Bitmap when you've supplied a mipmap source and have enabled setHasMipMap(). Now in Android 4.3, you can enable mipmaps for a BitmapDrawable object as well, by providing a mipmap asset and setting the android:mipMap attribute in a bitmap resource file or by calling hasMipMap().

我看不出有什么可以帮助我理解?

I don't see anything in there that helps me to understand?

XML位图资源: MIPMAP 属性:

布尔。启用或禁用的mipmap提示。见setHasMipMap()的   更多信息。默认值是假的。

Boolean. Enables or disables the mipmap hint. See setHasMipMap() for more information. Default value is false.

这并不适用于发射器的图标,只要我能看到的。

This does not apply to launcher icons as far as I can see.

提出的问题是在谷歌论坛(的资源名称纹理映射的目的是什么?!),到罗曼盖伊回答:

The question was raised on Google Groups (The purpose of resource name "mipmap"?!), to which Romain Guy replied:

这是很有用的,在一个更​​大的分辨率,将提供图像   通常被计算(例​​如,一个MDPI装置上,发射器可能   想要更大的华电国际图标,显示大型应用程序的快捷方式。)

It's useful to provide an image at a larger resolution that would normally be computed (for instance, on an mdpi device, Launcher might want the larger hdpi icon to display large app shortcuts.)

我觉得这几乎使得它的意义,但并不完全。

I feel like this almost makes sense of it, but not quite.

我还是倾向于去与兰迪Sugianto的跟进:

I'm still inclined to go with Randy Sugianto's follow up:

这有什么好处呢?是否有任何指导如何使用   贴图,可能是更好的启动器图标?

What are the advantages of this? Is there any guide how to use mipmaps, probably for better launcher icons?

当然,维基百科为MIP贴图,它指的是一个旧的技术发明于1983年的网页,即我不能完全涉及到目前Android的实现。


Of course, Wikipedia has a page for "Mipmap", which refers to an older technique invented in 1983, that I can't quite relate to the current Android implementation.

我们是否应该保存所有的应用图标 RES /纹理映射文件夹这几天,什么是指南对于这些纹理映射图像?

Should we be storing all our app icons in res/mipmap folders these days, and what are the guidelines for these mipmap images?

更新#1

下面是一个博客文章,试图解释这一点。

Here's a blog post that tries to explain it a bit.

  • <一个href="http://programmium.word$p$pss.com/2014/03/20/mipmapping-for-drawables-in-android-4-3/">Mipmapping在Android的可绘4.3

但是在博客文章中使用的图像显示了看起来像1文件中有许多标志的在里面。这不是我在Chrome的多重映像文件夹中看到。

But the image used in that blog post shows what looks like 1 file with many logo's in it. This is not what I see in Chrome's mipmap folder.

Chrome的纹理映射,华电国际文件夹包含3张图片。一个是铬标志,对自己。

Chrome's mipmap-hdpi folder contains 3 images. One is the Chrome logo, on its own.

奇怪的是,它的72x72,而不是48x48的,我希望看到的。

Strangely, it is 72x72, not 48x48 which I would expect to see.

也许这是所有有此 - 我们只需要保持更大的图标多重映像文件夹

Perhaps that is all there is to this - we just need to keep bigger icons in the mipmap folders?

更新#2

的23/10/2014在Android开发者博客文章再次证实使用纹理映射文件夹的应用程序图标的想法:

The Android Developers Blog post of 23/10/2014 again confirms the idea of using the mipmap folders for application icons:

  • <一个href="http://android-developers.blogspot.com/2014/10/getting-your-apps-ready-for-nexus-6-and.html">Getting您的应用程序准备的Nexus 6和Nexus 9

在谈到Nexus的6屏幕像素密度,作者写道:

When talking about the Nexus 6 screen density, the author writes:

这是把你的应用程序图标在mipmap-文件夹最佳实践(不   drawable-文件夹),因为它们使用的分辨率不同   该器件的电流密度。例如,一个xxxhdpi应用程序图标可   用于发射一个xxhdpi设备。

It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density. For example, an xxxhdpi app icon can be used on the launcher for an xxhdpi device.

更新#3

需要注意的是Android的工作室创建 ic_launcher.png 图标在纹理映射... 文件夹,而不是绘制... 文件夹的Eclipse用于在创建。

Note that Android Studio creates the ic_launcher.png icons in the mipmap... folders rather than the drawable... folders that Eclipse used to create them in.

推荐答案

有贴图两种不同的用法。

There are two distinct uses of mipmaps.

1)启动图标建筑密度特定的APK时。一些开发商为每密度建立单独的APK,以保持APK大小下来。然而,一些发射器(随一些设备,或可在Play商店),使用更大的图标尺寸比标准48dp。发射器使用getDrawableForDensity,如果需要,而不是向上缩小,所以图标是高品质的。例如在一个华电国际板的启动可能会加载xhdpi图标。通过将你的发射器图标的mipmap-xhdpi目录下,它不会被剥离的可绘制-xhdpi目录是华电国际设备建设APK时的方式。如果你正在构建一个单一的APK所有设备,那么这其​​实并不重要的发射器可以访问绘制资源所需的密度。

1) For launcher icons when building density specific APKs. Some developers build separate APKs for every density, to keep the APK size down. However some launchers (shipped with some devices, or available on the Play Store) use larger icon sizes than the standard 48dp. Launchers use getDrawableForDensity and scale down if needed, rather than up, so the icons are high quality. For example on an hdpi tablet the launcher might load the xhdpi icon. By placing your launcher icon in the mipmap-xhdpi directory, it will not be stripped the way a drawable-xhdpi directory is when building an APK for hdpi devices. If you're building a single APK for all devices, then this doesn't really matter as the launcher can access the drawable resources for the desired density.

2)从4.3实际的mipmap API。我没有用过这个,我不熟悉它。它不使用Android开源项目发射,我不知道使用任何其他发射器。

2) The actual mipmap API from 4.3. I haven't used this and am not familiar with it. It's not used by the Android Open Source Project launchers and I'm not aware of any other launcher using.

这篇关于纹理映射可绘制的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆