Posted By

sospartan on 03/18/11


Tagged

canvas bitmap android drawable ninepatch


Versions (?)

android ninepatchdrawable draw scalable


 / Published in: Java
 

  1. NinePatchDrawable drawable = (NinePatchDrawable) context.getResources().getDrawable(R.drawable.btn_default_normal);
  2. paint.setColor(Color.BLUE);
  3. int width = (int)this.mRect.width();
  4. int height = (int)this.mRect.height();
  5. drawable.setBounds(new Rect(0, 0, width,height));
  6. Bitmap b = Bitmap.createBitmap(width, height, Config.ARGB_8888);
  7. Canvas c = new Canvas(b);
  8. drawable.draw(c);
  9. canvas.drawBitmap(b, new Rect(0, 0, width, height), rect, paint);

Report this snippet  

You need to login to post a comment.