Android Preferences Overlaps Toolbar -


i have android app preference enter image description here

as can see preferences overlaps toolbar. main fragment xml

<?xml version="1.0" encoding="utf-8"?> <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">      <include         layout="@layout/app_bar_main"         android:layout_width="match_parent"         android:layout_height="match_parent" />       <framelayout         android:id="@+id/content"         android:layout_width="match_parent"         android:layout_height="match_parent">     </framelayout>      <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" />  </android.support.v4.widget.drawerlayout> 

which include new xml

<?xml version="1.0" encoding="utf-8"?> <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">      <android.support.design.widget.appbarlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:theme="@style/apptheme.appbaroverlay">          <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" />      </android.support.design.widget.appbarlayout>      <include         layout="@layout/content_main"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_below="@id/toolbar" />      <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" />  </android.support.design.widget.coordinatorlayout> 

and content_main.xml

<?xml version="1.0" encoding="utf-8"?> <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">      <textview         android:id="@+id/location"         android:paddingtop="30dp"         android:layout_width="wrap_content"         android:layout_height="wrap_content" /> </relativelayout> 

my xml preferences one

<?xml version="1.0" encoding="utf-8"?> <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent">     <preferencecategory         android:summary="username , password information"         android:title="informações de login">         <edittextpreference             android:key="username"             android:summary="introduzir username"             android:title="username" />         <edittextpreference             android:key="password"             android:summary="introduzir password"             android:title="password" />     </preferencecategory>     <preferencecategory         android:summary="sessao"         android:title="definições">         <preference             android:key="@string/mycoolbutton"             android:summary="mude aqui"             android:title="mudar password na bd" />         <checkboxpreference             android:key="checkbox"             android:summary="on/off"             android:title="manter sessão" />     </preferencecategory> </preferencescreen> 

and xml called settingsfragment.java

public class settingsfragment extends preferencefragmentcompat {     sharedpreferences sharedpreferences;      @override     public void oncreatepreferences(bundle bundle, string s) {         addpreferencesfromresource(r.xml.prefs);         sharedpreferences = preferencemanager.getdefaultsharedpreferences(getactivity());     } } 

so...why have problem , how can fix that?

update code asked

 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; } 

try align "content" frame layout in main.xml below "app_bar".

<include android:id="@+id/app_bar" layout="@layout/app_bar_main" android:layout_width="match_parent" android:layout_height="match_parent" />   <framelayout android:id="@+id/content" android:layout_below="@id/app_bar" android:layout_width="match_parent" android:layout_height="match_parent"/> 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -