title: Drawing in a Fragment in Android
body: <p>I have the following code:</p>
  
  <pre><code>import android.app.Fragment;
  import android.graphics.Rect;
  import android.graphics.Typeface;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.animation.AlphaAnimation;
  import android.widget.TextView;
  
  public class MainFragment extends Fragment {
  
  protected AlphaAnimation fadeIn = new AlphaAnimation(0.0f , 1.0f ); 
  
  
  public MainFragment(){}
  
  
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.main_fragment, container, false);
      String fontPath = "fonts/roboto.ttf";
      Typeface font = Typeface.createFromAsset(getActivity().getAssets(), fontPath);
  
      TextView txt1 = (TextView) rootView.findViewById(R.id.headerTextView);
      txt1.setTypeface(font); 
  
      TextView txt2 = (TextView) rootView.findViewById(R.id.instructions);
      txt2.setTypeface(font);
  
  
      txt1.startAnimation(fadeIn);
      txt2.startAnimation(fadeIn);
      fadeIn.setDuration(1400);
      fadeIn.setFillAfter(true);
  
      Rect rectangle = new Rect(200, 56, 200, 112);
  
  
      return rootView;
    }
  }
  </code></pre>
  
  <p>I'm trying to draw a rectangle, but for the life of me can't figure it out. I've looked everywhere for the onDraw() method, but I don't believe that is possible in a fragment.</p>