Reprint Please specify source: http://blog.csdn.net/zhaokaiqiang1992
about why use. 9 diagram, I will not be lengthy, is to reduce the volume of image resources, we focus on this article to solve. 9 diagram of the production of some small problems.
.9 of the production, is actually the original image to add the 1px boundary, and then according to our needs, the corresponding position is set to black line, the system will be based on our actual needs to stretch.
Is the explanation of the meaning of the four sides of the. 9 figure, the upper left represents the stretching area, the right bottom represents padding box, is the interval area, below, we give an example, convenient for everyone to understand.
Let's take a look at the two images below, and we'll understand what these four lines mean.
And the difference lies in the right bottom of the black line is not the same, the specific effect of the difference, look to the right. Medium-dark blue area, representing the content area, we can see is in the center, this is because we are at the bottom of the two points, the distance between the two points is padding, the distance between the left and right four is the distance, the dark blue content area in the center of the picture, we see, because the right bottom of the black line is the length So there is no padding, from the performance is the dark blue area and the image of the same size, so we can use the right bottom to control the content and the edge of the background image padding.
If you do not understand, then we look at the following, we are in figure I and figure two as the background map, the following is.
We can see that using the Wrap_content property to set the length-width, figure one than the effect of figure two large circle, this is why? Do you remember the padding I said above?
This is the padding effect of the withdrawal, how to prove it? Let's look at the following diagram, add padding=0 to figure one, so that the padding effect of the background map settings is gone, is it two as big?
OK, I think you should understand the meaning of the black line below the right, let's look at the effect on the top left.
Below we only set the left top line, as follows
The above line does not cover the icon, the following line is just wrapped in the icon, from the right side should be able to see the difference, black line is in the area is stretched area, black lines are all solid color, so the icon is not deformed, the following stretch area wrapped in the icon, so in the stretching time will be stretched on the icon, However, this can cause the icon to deform. Notice the Red line area below? This is the system prompt us, because this stretch, does not meet the requirements, so will be prompted.
Introduced so much, you should be able to use Ninepatch? No, leave a message, I see you answer questions, hehe
"Android interface Implementation" A little explanation of 9patch graphs in Android