the padding lines) by drawing a line on the right and bottom lines. If a View object sets the NinePatch as its background and then specifies the View's text, it will stretch itself so that all the text fits inside only the area designated by the right and bottom lines (if included)....
点击Show patches,能看到我们想要拉伸的内容,和不想被拉伸的内容。 Nine-Patch【.9】图片的使用和普通的png图片使用一样。在XML文件中对制作好的Nine-Patch【.9】图片进行使用,重新运行程序,结果如下图:
这种效果非常差,用户肯定是不能容忍的,这时我们就可以使用Nine-Patch图片来进行改善。 在Android SDK目录下有一个tools文件夹,在这个文件夹中找到draw9patch.bat文件 双击打开之后,把图片拖动到窗口中,将图片加载进来,如图所示: 我们可以在图片(左边)的四个边框绘制线段,线段内的部分就表示当前图片拉伸的区域,拉伸后...
android:text="正文:A NinePatchDrawable graphic is a stretchable bitmap image, which Android will automatically resize to accommodate the contents of the View in which you have placed it as the background. A NinePatch drawable is a standard PNG image that includes an extra 1-pixel-wide border...
Nine-Patch图片是一种经过特殊处理的png图片,能够指定图片的哪些区域可以被拉伸而哪些区域不可以。 普通图片被拉伸时的缺陷 有如下xml文件,其中子LinearLayout的背景图片设置成一个名为chat的png图片: <?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/androi...
NinePatchDrawable XML属性 <nine-patch xmlns:android="http://schemas.android.com/apk/res/android" android:src="drawable/resource" //android:dither是否允许抖动,如果位图与屏幕的像素配置不同时,开启这个选项可以让高质量的图片在低质量的屏幕上保持较好的显示效果(例如:一个位图的像素设置是 ARGB 8888,但屏幕...
nine-patch图片的制作 4.1.4. 用户界面流程适配 根据屏幕的配置来加载相应的用户界面流程。 使用场景:我们会根据设备特点显示恰当的布局,但是这样做,会使得用户界面流程可能会有所不同。 例如:如果应用处于双面板模式下,点击左侧面板上的项即可直接在右侧面板上显示相关内容;而如果该应用处于单面板模式下,点击...
之前写了一篇文章Android必知必会–NinePatch图片制作详细介绍了Android9Patch图片的制作和一些Demo展示,这次说明一下9Patch图片的制作的注意事项和遇到相关报错的解决方案。 一、注意事项 9Patch图片的左边框和上边框至少有一个描点,右边框和下边框则有且只有一段描点。
10.6.4 XML Nine-Patch图像资源 Nine-Patch图像资源也有与其对应的XML图像资源,这一点与普通图像资源类似。只是使用<nine-patch>标签来引用Nine-Patch格式的图像,而且属性比<bitmap>标签少了很多,只有一个设置抖动的android:dither属性。下面是一个定义XML Nine-Patch图像资源的例子。 <?xml version="1.0" encoding...
在你Android SDK 路径下 X:\android sdk\tools ,你会找到一个 【draw9patch.bat】,没错这就是9妹啦、官方名 NinePatch ; 提示导入一张png图片,然后真正进入"9妹"的操作界面(如下图): (图1) 序列① :在拉伸区域周围用红色边框显示可能会对拉伸后的图片产生变形的区域,如果完全消除该内容则图片拉伸后是没...