1. 制作.9.png图片

  2. 编译制作好的图片

  3. NinePathDrawable解析:


  4. publicstaticDrawabledecodeStream(Resourcesresources,InputStreamis,Optionsoptions)throwsIOException{Bitmapbitmap=BitmapFactory.decodeStream(is);byte[]chunks=bitmap.getNinePatchChunk();booleanisNinePatchChunk=NinePatch.isNinePatchChunk(chunks);Log.v(TAG,"isNinePatchChunk:"+isNinePatchChunk);if(!isNinePatchChunk){returnnewBitmapDrawable(resources,bitmap);}else{Rectpadding=newRect();padding.left=getInt(chunks,12);padding.right=getInt(chunks,16);padding.top=getInt(chunks,20);padding.bottom=getInt(chunks,24);returnnewNinePatchDrawable(resources,bitmap,chunks,padding,null);}}privatestaticintgetInt(byte[]chunk,intfrom){intresult=0;result=((result<<8)|(chunk[from+3]&0xFF));result=((result<<8)|(chunk[from+2]&0xFF));result=((result<<8)|(chunk[from+1]&0xFF));result=((result<<8)|(chunk[from+0]&0xFF));returnresult;}

更多相关文章

  1. android转页面
  2. Android一行代码 搞定图片太多,太大OOM(内存溢出)
  3. Android加载网络图片
  4. Android:用ViewPager实现广告栏
  5. 带图片的按钮-Android源代码
  6. Android(安卓)长按识别图中二维码 zxing
  7. Drawable、Bitmap、byte[]之间的转换
  8. Android(安卓)使用Glide加载图片变色

随机推荐

  1. Camera构架分析
  2. Lottie for Android(安卓)实战使用总结
  3. Android横屏竖屏切换的问题
  4. [Android]实现静默安装APK的两种方法
  5. Android(安卓)CheckBox中设置padding无效
  6. Android基础知识:Day02 常见布局、logcat
  7. android 隐藏EditText光标
  8. NetBeans 7.0 安装 Android(安卓)SDK 开
  9. 升级android sdk到5.0时,创建项目出现错误
  10. android之ContentResolver与ContentProvi