Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does a 9patch png work in android apps

In a 9patch png, there are black edges in its four sides, but there is usually difference between the left to right, and the up to down side. Why? How does this difference impact?

like image 501
Yunfei Tang Avatar asked Dec 23 '10 10:12

Yunfei Tang


3 Answers

One of simplest ans is this pic

draw the black line according to your requirement using nine patch tools.

like image 74
Akram Avatar answered Oct 29 '22 05:10

Akram


The left and top are for scaling, and the right and bottom are for content. So the black lines on left and top will scale to fit, and the content for a button will be "inside" the black lines on the right and bottom.

like image 45
Espen Avatar answered Oct 29 '22 06:10

Espen


Here http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch you can find a very good explanation, with images to show you that the left and top part of the black border indicate a stretchable section, while the right and bottom lines define the drawable area, where you can put your content.

like image 34
Adinia Avatar answered Oct 29 '22 05:10

Adinia