在Android SDK安装路径下的tools目录下找到draw9path.bat,双击运行。制作9Path图片。

layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<Button android:text="普通图片作为Button背景" android:textSize="20dip"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/myselectora" />
<Button android:text="9Patch图片作为Button背景" android:textSize="20dip"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/myselectorb" />
</LinearLayout>

第二个按钮的背景为9patch图片,被拉伸后如下:

更多相关文章

  1. Android剪切图片
  2. android xml中设置自适应图片
  3. Android(安卓)Gallery的使用
  4. Android(安卓)之 ImageView(图片组件)
  5. Android使用Shape实现布局圆角边框
  6. android selector的使用
  7. android多点触摸缩放图片
  8. android imageVIew拖动 && 图片缩放
  9. 图片走廊

随机推荐

  1. android 混淆代码
  2. Android:获取屏幕的宽度和高度
  3. 点击按钮之后仍然显示对话框--Android
  4. Android(安卓)USB Host 使用详解(U盘)(三)
  5. android 原生 电子邮件 应用 发送邮件附
  6. android故障与Log的对应
  7. Android(安卓)Studio 自动代码提示设置
  8. android 用shape oval属性画圆环变成黑圆
  9. 在xml文件的Preference标签中,用给标签加
  10. Android(安卓)Netroid解析之——断点续传