android drawable micro-tricks

Source: http://blog.csdn.net/guolin_blog/article/details/50727753 It seems that I haven't updated my blog for a long time. Recently, I spent a long time studying the source code in order to prepare the next series of blogs. It is a pity that I may have to wait for a while to write the next series of blogs, so in order not to make you wait too long, I will update you a single article today to talk about Android drawables. micro-tricks. 
 


By the way, the word micro-skill is also invented by me, because drawable is believed to be used by everyone every day, and everyone is familiar with it. The reason why it is called micro-skill is that we are familiar with this technology. If you don't know the details, let's explore these tiny details together today. Everyone knows that in Android projects, the drawable folder is used to place image resources, whether it is jpg, png, or 9.png, you can put it here. In addition, there are xml files like selectors that can also be placed under the drawable folder. But if you now use Android Studio to create a new project, you will find the following directory structure: 
 
 


Um? How come there are so many folders that start with mipmap, and their naming rules are very similar to the drawable folder, they are also hdpi, mdpi, xhdpi, etc., and there are really pictures in them. Is the location of the pictures in the Android project changed? already?  
Developers who have just switched from Eclipse to Android Studio may be unfamiliar with the mipmap folder. In fact, don't worry, our usual programming habits do not need to be changed, because the mipmap folder is only used to place the icon of the application. That's all. So before that, we put the application's icon icon and ordinary image resources in the drawable folder together, so it looks messy, sometimes we want to find the icon from a bunch of image resources for a long time I can't find it either, and if there are too many files, it is easy to leak, but it is precisely Android that it is highly recommended that we put an icon of the corresponding size under the folder of each resolution, so they are separated and specially designed. Putting it in the mimap folder solves this problem very well.  
In addition, placing the icon in the mipmap folder can also allow the launcher icon of our program to automatically have the ability to display across device densities. For example, a device with a screen density of xxhdpi can automatically load the icon under mipmap-xxxhdpi as the application's icon. launcher icon, so the icon will look more delicate.  
For the original text that recommends using mipmaps, you can refer to this article: Getting Your Apps Ready for Nexus 6 and Nexus 9 , of course, you still have to surf the Internet scientifically.  
In addition, Android also gives the best advice on what size the icon should be designed for each density. It is best not to design the size of the icon arbitrarily, because too low a resolution will cause the icon to be blurred, and too high a resolution will cause the icon to be blurred. resolution will simply increase the APK size. Recommended sizes are shown in the table below:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326426797&siteId=291194637