开发者

When To Use 9-Patch

开发者 https://www.devze.com 2023-03-05 13:35 出处:网络
Is there any Android developer documentation that says when drawable resources can be 9-patch?To put it another way, is there a document that says something along the lines of \"the following items us

Is there any Android developer documentation that says when drawable resources can be 9-patch? To put it another way, is there a document that says something along the lines of "the following items use 9-patch data, if available"?

From poking around and experience, I've learned that 9-patch graphics should be used for

  • application launcher icons
  • icons used in the "Add to Home screen" selection list for App Widgets, Wallpapers, and Folders
  • desktop wallpapers and when otherwise using BitMaps, e.g. on canvases
  • button graphics
  • view backgrounds

I've been surprised to see that 9-patch data is ignored w开发者_JAVA技巧hen drawables are used for menu icons and tab icons.


9-patches is best used when you have an image that needs a fluid width and/or height.

Example: In my app I had two custom buttons that stretched across the bottom of the view. Because screen sizes can differ, I used 9-patches to allow the buttons to stretch correctly.

0

精彩评论

暂无评论...
验证码 换一张
取 消