title: How to set size of nine-patch drawable programmatically in android
body: <p>This is how we can resize a normal bitmap drawable</p>
  
  <pre><code> Drawable d = getResources().getDrawable(R.drawable.error);
      Bitmap bm = ((BitmapDrawable)d).getBitmap();
  
      error_indicator = new BitmapDrawable(getResources(), bm.createScaledBitmap(bm, 50, 50, true));
  </code></pre>
  
  <p>But I want to know how to resize a nine patch drawable. since the above code doesnt works for me giving me ClassCastException saying NinePatchDrawable cannot be cast to BitmapDrawable.
  <img src="https://i.stack.imgur.com/6ANn5.png" alt="error drawable"></p>
  
  <p>This is nine-patch drawable(hdpi).I have other resolutions icons too</p>
  
  <p>Draw 9-patch tool screenshot</p>
  
  <p><img src="https://i.stack.imgur.com/Z4i5k.png" alt="enter image description here"></p>
  
  <p>App Screenshot</p>
  
  <p><img src="https://i.stack.imgur.com/OoikE.png" alt="enter image description here"></p>