title: Drawing shapes programmatically for Android
body: <p>I'm new to the Android SDK so I'm trying to figure this out. I have read the documentation and a text book and they haven't been particularly helpful in this matter. </p>
  
  <p>I'm just trying to draw a simple rectangle in a linear layout on the screen. I can't get the shape to show up, however, when I add text to this layout in the same fashion, the text does show up. What am I missing?</p>
  
  <pre><code>package jorge.jorge.jorge;
  
  import android.app.Activity;
  import android.graphics.Color;
  import android.graphics.drawable.ShapeDrawable;
  import android.graphics.drawable.shapes.RectShape;
  import android.os.Bundle;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  
  public class ShapesActivity extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          ShapeDrawable rect = new ShapeDrawable(new RectShape());
  
          rect.getPaint().setColor(Color.GREEN);
  
          ImageView view1 = new ImageView(this);
  
          view1.setImageDrawable(rect);
  
          LinearLayout frame = (LinearLayout)findViewById(R.id.linear1);
  
          frame.addView(view1);
  
  //        TextView tx = new TextView(this);
  //        
  //        tx.setText("Hello World");
  //        
  //        frame.addView(tx);
      }
  }
  </code></pre>