title: Slow navigation drawer
body: <p>My navigation drawer lags when I open complex view. Here is my MenuActivity code:</p>
  
  <pre><code>public class MenuActivity extends AppCompatActivity implements View.OnClickListener {
  
  private DrawerLayout mDrawer;
  private Toolbar toolbar;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_menu);
      // Set a Toolbar to replace the ActionBar.
      toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);
  
      mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
  
      // Set the menu icon instead of the launcher icon.
      getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_menu);
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
      // Setup drawer view
      findViewById(R.id.building_status_fragment).setOnClickListener(this);
      findViewById(R.id.news_fragment).setOnClickListener(this);
      findViewById(R.id.register_fragment).setOnClickListener(this);
      findViewById(R.id.phone_view).setOnClickListener(this);
      findViewById(R.id.services_fragment).setOnClickListener(this);
      findViewById(R.id.contacs_fragment).setOnClickListener(this);
      // first init
      getFragmentManager().beginTransaction().replace(R.id.container, new BuildingStatusFragment()).commit();
      setTitle(getString(R.string.title_building_progress)); // toolbar.setTitle dont work, hm
  }
  
  @Override
  public void onClick(View v) {
      mDrawer.closeDrawers();
      FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
      switch(v.getId()) {
          case R.id.building_status_fragment:
              fragmentTransaction.replace(R.id.container, new BuildingStatusFragment());
              toolbar.setTitle(getString(R.string.title_building_progress));
              break;
          case R.id.news_fragment:
              fragmentTransaction.replace(R.id.container, new NewsFeedFragment());
              toolbar.setTitle(getString(R.string.title_news));
              break;
          case R.id.register_fragment:
              fragmentTransaction.replace(R.id.container, new RegisterFragment());
              toolbar.setTitle(getString(R.string.title_look));
              break;
          case R.id.services_fragment:
              fragmentTransaction.replace(R.id.container, new ServicesFragment());
              toolbar.setTitle(getString(R.string.title_services));
              break;
          case R.id.contacs_fragment:
              fragmentTransaction.replace(R.id.container, new ContactsFragment());
              toolbar.setTitle(getString(R.string.title_contacts));
              break;
          case R.id.phone_view:
              startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:74996782873")));
              break;
      }
      fragmentTransaction.commit();
  }
  
  
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
          case android.R.id.home:
              // https://stackoverflow.com/questions/13721049/how-to-hide-default-keyboard-when-click-on-menu
              if(getCurrentFocus() != null &amp;&amp; getCurrentFocus() instanceof EditText){
                  InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                  imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
              }
              mDrawer.openDrawer(GravityCompat.START);
              return true;
      }
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I have "complex" view with 2 images:</p>
  
  <pre><code>&lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="@color/white"
  android:scrollbars="none"&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="#fff"&gt;
  
          &lt;ImageView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_centerInParent="true"
              android:adjustViewBounds="true"
              android:src="@drawable/auto" /&gt;
  
          &lt;TextView
              android:id="@+id/toptext"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_alignParentTop="true"
              android:layout_marginLeft="17dp"
              android:layout_marginTop="17dp"
              android:background="#B300A3DA"
              android:paddingLeft="6dp"
              android:paddingRight="6dp"
              android:text="Покупка"
              android:textColor="#fff"
              android:textSize="18sp" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_below="@+id/toptext"
              android:layout_marginLeft="17dp"
              android:layout_marginTop="4dp"
              android:background="#B300A3DA"
              android:paddingLeft="6dp"
              android:paddingRight="6dp"
              android:text="машиномест"
              android:textColor="#fff"
              android:textSize="18sp" /&gt;
  
          &lt;!--Костыль--&gt;
          &lt;LinearLayout
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_centerHorizontal="true"
              android:paddingBottom="15dp"&gt;
              &lt;!--Костыль--&gt;
              &lt;LinearLayout
                  android:id="@+id/auto_form"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:background="#B3000000"
                  android:orientation="vertical"
                  android:paddingBottom="7dp"
                  android:paddingLeft="50dp"
                  android:paddingRight="50dp"
                  android:paddingTop="7dp"&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center_horizontal"
                      android:text="Посмотреть"
                      android:textColor="@color/white"
                      android:textSize="18sp" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center_horizontal"
                      android:text="предложение"
                      android:textColor="@color/white"
                      android:textSize="18sp" /&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/RelativeLayout&gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:background="#fff"&gt;
  
          &lt;ImageView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_centerInParent="true"
              android:adjustViewBounds="true"
              android:src="@drawable/rights" /&gt;
  
          &lt;TextView
              android:id="@+id/toptext2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentLeft="true"
              android:layout_alignParentTop="true"
              android:layout_marginLeft="17dp"
              android:layout_marginTop="17dp"
              android:background="#B300A3DA"
              android:paddingLeft="6dp"
              android:paddingRight="6dp"
              android:text="Оформление"
              android:textColor="#fff"
              android:textSize="18sp" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_below="@+id/toptext2"
              android:layout_marginLeft="17dp"
              android:layout_marginTop="4dp"
              android:background="#B300A3DA"
              android:paddingLeft="6dp"
              android:paddingRight="6dp"
              android:text="прав собственности"
              android:textColor="#fff"
              android:textSize="18sp" /&gt;
          &lt;!--Костыль--&gt;
          &lt;LinearLayout
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_centerHorizontal="true"
              android:paddingBottom="15dp"&gt;
              &lt;!--Костыль--&gt;
              &lt;LinearLayout
                  android:id="@+id/rights_form"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:background="#B3000000"
                  android:orientation="vertical"
                  android:paddingBottom="7dp"
                  android:paddingLeft="50dp"
                  android:paddingRight="50dp"
                  android:paddingTop="7dp"&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center_horizontal"
                      android:text="Посмотреть"
                      android:textColor="@color/white"
                      android:textSize="18sp" /&gt;
  
                  &lt;TextView
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:layout_gravity="center_horizontal"
                      android:text="предложение"
                      android:textColor="@color/white"
                      android:textSize="18sp" /&gt;
              &lt;/LinearLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/RelativeLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>
  
  <p>And it lags every time when I open this fragment. Also I noticed that fragment with map view also have some lags. I read <a href="https://stackoverflow.com/questions/20164633/navigation-drawer-is-slow-with-complex-view">this post</a> and looks like I should do all my work after navigation drawer is closed (if I call mDrawer.closeDrawers() before fragment transaction isn't it the same??), but what the reason for lags if I open drawer when fragment with complex view is already initialized? It is very strange for me.</p>
  
  <p>Also debugger said that uithread takes 2 much work and skip frames.So should I optimize my "complex" fragments or optimize navigation drawer appears? And how? Thx</p>