新建9-Patch
res->xxx.png 中右键打开选项,点击create 9-Patch file,即可生成尾缀为xxx.9.png的文件
9-Patch编辑栏的参数含义
- Zoom 左侧编辑栏大小
- Patch scale 右侧预览栏大小
- Show content 内容放置区域(图中紫色区域),如给TextView设置.9.png的background,在紫色区域放置Text
- Show patches 编辑大小
制作9-Patch
- 调整左上两条线的大小设置拉伸区域
- 调整右小两条线的大小设置内容区域
- 点击左键新增区域,点击Shift+左键删除
使用9-Patch
在xml文件中使用
<TextView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_below="@+id/btn_tiny"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:background="@mipmap/bubble"
android:text="@string/str_long"
android:textSize="30sp" />