When To Use 9-Patch

风流意气都作罢 提交于 2019-12-06 06:57:15

问题


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 when drawables are used for menu icons and tab icons.


回答1:


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.



来源:https://stackoverflow.com/questions/5995880/when-to-use-9-patch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!