android ninepatchdrawable draw scalable


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.