Android Nine patch picture and button background

Source: Internet
Author: User
Tags relative

ninepatchdrawable painting is a scalable bitmap image, Android will automatically resize to accommodate the displayed content. An example is the Ninepatch for the background, using the standard Android button, the button must be scaled to accommodate the length of the changed characters

Ninepatchdrawable is a standard PNG image that includes an extra 1 pixel boundary, and you must save it with a suffix of. 9.png and remain in the engineering res/drawable directory. If you are extracting the *.9.png file from the APK, note that it has been removed from the surrounding blank pixels and must be added when used.

This boundary is used to determine the scalable and static area of the image. You can draw one or more black 1 pixels on the left and top of the line to point out the retractable part (you can need a lot of retractable parts), its relative position is the same in the scalable part, so the large part is always very large.

You can also draw an optional drawable area on the right and bottom of the image (valid, inner margin lines). If your view object is set Ninepath to the background and then specify a special view font, it will flex itself so that all the text adapts to the area (if any) that is designed according to the right and bottom lines, and of course the inner margin line does not include it, and Android can use the line on the left to define a Drawable area.

Let's clarify the two different lines, the left and top lines to define which pixels of the image are allowed to be copied when scaling.

The bottom and right lines are used to define an image in a relative position, and the contents of the view are placed in it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.