title: Setting an ImageView resource as a Drawable
body: <p>I am trying to create a drawable in code and change the color based on some criteria. When I try and set the Drawable as the background of the ImageView it displays but won't let me set any padding. I realized I need to set the ImageView image via the setImageDrawable() function in order to be able to set the padding. </p>
  
  <p>The problem I am running into is that when I set it via the setImageDrawable() function nothing is displayed. </p>
  
  <p>Here is what I have written:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>
  
  <p></p>
  
  <p></p>
  
  <pre><code>            ImageView icon = (ImageView) row.findViewById(R.id.icon);
    ShapeDrawable mDrawable;
  
    int x = 0;
       int y = 0;
       int width = 50;
       int height = 50;
  
       float[] outerR = new float[] { 12, 12, 12, 12, 12, 12, 12, 12 };
  
       mDrawable = new ShapeDrawable(new RoundRectShape(outerR, null, null));
       mDrawable.setBounds(x, y+height, x + width, y);
  
  
  
    switch(position){
  
    case 0:
     mDrawable.getPaint().setColor(0xffff0000);  //Red
     break;
    case 1:
     mDrawable.getPaint().setColor(0xffff0000);  //Red
     break;
    case 2:
     mDrawable.getPaint().setColor(0xff00c000);  //Green
     break;
    case 3:
     mDrawable.getPaint().setColor(0xff00c000);  //Green
     break;
    case 4:
     mDrawable.getPaint().setColor(0xff0000ff);  //Blue
     break;
    case 5:
     mDrawable.getPaint().setColor(0xff0000ff);  //Blue
     break;
    case 6:
     mDrawable.getPaint().setColor(0xff696969);  //Gray
     break;
    case 7:
     mDrawable.getPaint().setColor(0xff696969);  //Gray
     break;
    case 8:
     mDrawable.getPaint().setColor(0xffffff00);  //Yellow
     break;
    case 9:
     mDrawable.getPaint().setColor(0xff8b4513);  //Brown
     break;
    case 10:
     mDrawable.getPaint().setColor(0xff8b4513);  //Brown
     break;
    case 11:
     mDrawable.getPaint().setColor(0xff8b4513);  //Brown
     break;
    case 12:
     mDrawable.getPaint().setColor(0xffa020f0);  //Purple
     break;
    case 13:
     mDrawable.getPaint().setColor(0xffff0000);  //Red
     break;
    case 14:
     mDrawable.getPaint().setColor(0xffffd700);  //Gold
     break;
    case 15:
     mDrawable.getPaint().setColor(0xffff6600);  //Orange
     break;
    }
  
       icon.setImageDrawable(mDrawable);
       icon.setPadding(5, 5, 5, 5);
  </code></pre>
  
  <p>This results in a space for the ImageView but no image. </p>
  
  <p>Thanks, 
  Rob</p>