title: SetContentView() taking time even though layout is very simple and light
body: <p>My <code>setContentView()</code> is taking around 3 seconds to load even though it has very simple layout withouht any custom views.</p>
  
  <p>xml layout:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/homeScreenLayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity" &gt;
  
  &lt;RelativeLayout
      android:id="@+id/mainview"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@drawable/bg_home"
      android:orientation="vertical" &gt;
  
      &lt;LinearLayout
          android:id="@+id/homeButtonsLayout"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_centerInParent="true"
          android:orientation="vertical"
          android:paddingLeft="10dp"
          android:paddingRight="10dp" &gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal" &gt;
  
              &lt;Button
                  android:id="@+id/btnHomeSearch"
                  android:layout_width="90dp"
                  android:layout_height="90dp"
                  android:layout_centerInParent="true"
                  android:layout_gravity="center_horizontal"
                  android:layout_marginTop="30dp"
                  android:background="@drawable/some_drawable" /&gt;
  
              &lt;TextView
                  android:id="@+id/tvHomeSearch"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_below="@id/btnHomeSearch"
                  android:gravity="center_horizontal"
                  android:paddingTop="5dp"
                  android:text="Some text"
                  android:textColor="#fff"
                  android:textSize="20sp" /&gt;
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal" &gt;
  
              &lt;Button
                  android:id="@+id/btnHomeClip"
                  android:layout_width="90dp"
                  android:layout_height="90dp"
                  android:layout_centerInParent="true"
                  android:layout_marginTop="30dp"
                  android:background="@drawable/some_drawable" /&gt;
  
              &lt;TextView
                  android:id="@+id/tvHomeClip"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_below="@id/btnHomeClip"
                  android:gravity="center_horizontal"
                  android:paddingTop="5dp"
                  android:text="Some text"
                  android:textColor="#fff"
                  android:textSize="20sp" /&gt;
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:layout_marginBottom="20dp" &gt;
  
              &lt;Button
                  android:id="@+id/btnSeeAll"
                  android:layout_width="90dp"
                  android:layout_height="90dp"
                  android:layout_centerInParent="true"
                  android:layout_marginTop="30dp"
                  android:background="@drawable/some_drawable" /&gt;
  
              &lt;TextView
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_below="@id/btnSeeAll"
                  android:gravity="center_horizontal"
                  android:paddingTop="5dp"
                  android:text="Some text"
                  android:textColor="#fff"
                  android:textSize="20sp" /&gt;
          &lt;/RelativeLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p></p>
  
  <hr>
  
  <p>Below is the piece of onCreate():</p>
  
  <pre><code>Log.i("PN","Main onCreate() start");
  setContentView(R.layout.main_flipper);
  Log.i("PN","Main onCreate() aftr setContentView");
  </code></pre>
  
  <p>this <code>ViewFlipper</code> has only 2 layouts. 2nd layout is also lightweight.</p>
  
  <hr>
  
  <p>Corresponding Log:</p>
  
  <pre><code>11-12 09:23:01.622: I/PN(12081): Main onCreate() start
  11-12 09:23:04.324: I/PN(12081): Main onCreate() aftr setContentView
  </code></pre>
  
  <p>Note that <code>setContentView()</code> is taking approx 3 seconds which is quite high.</p>
  
  <p>Any idea why this is happening?</p>
  
  <p>Any help appreciated.</p>
  
  <h2>Edit</h2>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      try {
          Log.i("PN","Main onCreate() start");
          // Set the design screen for the code
          // Activate full screen for this flow
          this.requestWindowFeature(Window.FEATURE_NO_TITLE);
          this.getWindow().setFlags(
                  WindowManager.LayoutParams.FLAG_FULLSCREEN,
                  WindowManager.LayoutParams.FLAG_FULLSCREEN);
  
          setContentView(R.layout.main_flipper);
          Log.i("PN","Main onCreate() aftr setContentView");
  
          Bundle b = getIntent().getExtras();
          Log.i("PN","Main onCreate() aftr getExtras");
          int viewNo = 0;
          if (b != null) {
              viewNo = b.getInt("View");
          }
  
          initVariables();
  
          setOnClickListeners();
          initSearchView();
          setTextWatcher();
          vf.setDisplayedChild(viewNo);
  
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <hr>
  
  <p>updated Log:</p>
  
  <pre><code>11-12 09:42:12.532: I/PN(14342): Main onCreate() start = 1384249332537
  11-12 09:42:15.122: I/PN(14342): Main onCreate() aftr setContentView = 1384249335125
  11-12 09:42:15.142: I/PN(14342): Main onCreate() aftr getExtras = 1384249335142
  11-12 09:42:15.142: I/PN(14342): Main onCreate() b4 init = 1384249335142
  11-12 09:42:15.392: I/PN(14342): Main onCreate() End = 1384249335396
  </code></pre>
  
  <p>As we can see, main delay is happening in setting up <code>setContentView()</code></p>
  
  <h2>Edit (2)</h2>
  
  <p>updated Log:</p>
  
  <pre><code>11-12 09:48:11.342: I/PN(15081): Main onCreate() start = 1384249691345
  11-12 09:48:11.372: I/PN(15081): Main onCreate() aftr FLAG_FULLSCREEN = 1384249691372
  11-12 09:48:13.961: I/PN(15081): Main onCreate() aftr setContentView = 1384249693970
  </code></pre>