如果要使用9补丁 [英] When To Use 9-Patch
问题描述
有没有Android开发者文档说,当绘制资源可以是9补丁?为了把它的另一种方式,就是有一个文件,说沿着下列项目使用9补丁数据,如果用?
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"?
这是闲逛和经验,我已经了解到,9补丁显卡应该用于
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
我一直惊讶地看到,当可绘制用于菜单图标和标签图标9补丁数据被忽略。
I've been surprised to see that 9-patch data is ignored when drawables are used for menu icons and tab icons.
推荐答案
9的补丁,最好使用当你有需要的液体宽度和/或高度的图像。
9-patches is best used when you have an image that needs a fluid width and/or height.
例如:在我的应用我有两个自定义按钮,整个视图的底部伸出。由于屏幕尺寸可能不同,我用9修补程序,以使按钮正常伸展。
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.
这篇关于如果要使用9补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!