问题
I'm going to use vector drawable feature for action bar icons and notification icon, on my app.
With the announce of Android N, one of his most important feature is Screen Zoom (on Accessibility Improvements section). Another interesting feature is Multi-window support (see link if you want more info).
Does this means that we should use vector drawable also for launcher icon and other images used on app?
回答1:
Vector drawable is not supported for launcher icons. You are, however, encouraged to use it everywhere else.
回答2:
You can use vector drawables as launcher icon if you follow these steps:
Place vector launcher icon under
drawable
directory. You can't place vector drawables inmipmap
directory because they will work only in API levels 21 and above. As you possible know it's recommended to place PNG launcher icons undermipmap-<density>
directories instead ofdrawable-<density>
ones, and this matters because if you have a split apk build or use the newaab
format to upload your app ("Google Dynamic Delivery"), both processes will remove alldrawable-<density>
directories except the one for the current density.Remove
vectorDrawables.useSupportLibrary = true
inbuild.gradle
defaultConfig
section if you set it earlier. This will enable build-time PNG generation for vector drawables for API levels lower then 21. If you do not remove this option thanandroid:icon
attribute of the<application>
tag will load default Android "green robot" icon.
I tested it on API level 16 device and it works perfectly.
回答3:
It seems vector drawables are now supported for launcher icons. I have recently uploaded and published an app (to alpha) with a vector drawable as a laucher icon.
来源:https://stackoverflow.com/questions/35912428/android-vector-drawable-for-launcher-icon-and-other-images-on-android-n