title: Android Preferences Overlaps Toolbar
body: <p>I have an android app with preference
  <a href="https://i.stack.imgur.com/AnTN6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AnTN6.png" alt="enter image description here"></a></p>
  
  <p>As you can see the preferences overlaps the toolbar.
  This is my main fragment xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v4.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:openDrawer="start"&gt;
  
      &lt;include
          layout="@layout/app_bar_main"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
  
      &lt;FrameLayout
          android:id="@+id/content"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
      &lt;/FrameLayout&gt;
  
      &lt;android.support.design.widget.NavigationView
          android:id="@+id/nav_view"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:fitsSystemWindows="true"
          app:headerLayout="@layout/nav_header_main"
          app:menu="@menu/activity_main_drawer" /&gt;
  
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>which include a new <code>xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:fitsSystemWindows="true"
      tools:context=".MainActivity"&gt;
  
      &lt;android.support.design.widget.AppBarLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:theme="@style/AppTheme.AppBarOverlay"&gt;
  
          &lt;android.support.v7.widget.Toolbar
              android:id="@+id/toolbar"
              android:layout_width="match_parent"
              android:layout_height="?attr/actionBarSize"
              android:background="?attr/colorPrimary"
              app:popupTheme="@style/AppTheme.PopupOverlay" /&gt;
  
      &lt;/android.support.design.widget.AppBarLayout&gt;
  
      &lt;include
          layout="@layout/content_main"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_below="@id/toolbar" /&gt;
  
      &lt;android.support.design.widget.FloatingActionButton
          android:id="@+id/fab"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="bottom|end"
          android:layout_margin="@dimen/fab_margin"
          android:src="@android:drawable/ic_partial_secure" /&gt;
  
  &lt;/android.support.design.widget.CoordinatorLayout&gt;
  </code></pre>
  
  <p>and finally the <code>content_main.xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      app:layout_behavior="@string/appbar_scrolling_view_behavior"
      tools:context="com.example.gilca.ebspma.MainActivity"&gt;
  
      &lt;TextView
          android:id="@+id/location"
          android:paddingTop="30dp"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>My <code>xml</code> preferences are this one</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
      &lt;PreferenceCategory
          android:summary="Username and password information"
          android:title="Informações de Login"&gt;
          &lt;EditTextPreference
              android:key="username"
              android:summary="Introduzir username"
              android:title="Username" /&gt;
          &lt;EditTextPreference
              android:key="password"
              android:summary="Introduzir password"
              android:title="Password" /&gt;
      &lt;/PreferenceCategory&gt;
      &lt;PreferenceCategory
          android:summary="sessao"
          android:title="Definições"&gt;
          &lt;Preference
              android:key="@string/myCoolButton"
              android:summary="Mude aqui"
              android:title="Mudar a password na BD" /&gt;
          &lt;CheckBoxPreference
              android:key="checkBox"
              android:summary="On/Off"
              android:title="Manter Sessão" /&gt;
      &lt;/PreferenceCategory&gt;
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <p>And this <code>xml</code> is called from <code>SettingsFragment.java</code></p>
  
  <pre><code>public class SettingsFragment extends PreferenceFragmentCompat {
      SharedPreferences sharedPreferences;
  
      @Override
      public void onCreatePreferences(Bundle bundle, String s) {
          addPreferencesFromResource(R.xml.prefs);
          sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
      }
  }
  </code></pre>
  
  <p>So...why do i have this problem and how can i fix that?</p>
  
  <p>UPDATE
  The code asked</p>
  
  <pre><code> public boolean onNavigationItemSelected(MenuItem item) {
      Fragment fragment = null;
      Class fragmentClass = null;
      int id = item.getItemId();
      if (id == R.id.nav_home) {
          fragmentClass = HomeFragment.class;
      } else if (id == R.id.nav_req) {
  
  
      } else if (id == R.id.nav_ver) {
  
      } else if (id == R.id.nav_atividades) {
          fragmentClass = AtividadesFragment.class;
      } else if (id == R.id.nav_training) {
          fragmentClass = TrainingFragment.class;
      } else if (id == R.id.nav_settings) {
          fragmentClass = SettingsFragment.class;
      }
      else if (id == R.id.nav_about) {
      }
      else if (id == R.id.nav_sair) {
          session.logOut();
          System.exit(0);
      }
      try{
          assert fragmentClass != null;
          fragment = (Fragment) fragmentClass.newInstance();
      }catch (Exception e) {
          e.printStackTrace();
      }
  
      FragmentManager fragmentManager = getSupportFragmentManager();
      fragmentManager.beginTransaction().replace(R.id.content, fragment).commit();
  
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      drawer.closeDrawer(GravityCompat.START);
      return true;
  }
  </code></pre>