android - Navigation Drawer not occupying the entire screen height -


i have drawer layout drawer on left.

drawer has button on click of want replace view of drawer new view. the problem , when new view gets replaced doesn’t occupy entire screen height.

to illustrate have given background colour navigation drawer views.

i want green view occupy entire screen height. copy-paste code below going: mainactivity.java

public class mainactivity extends activity { layoutinflater inflater; drawerlayout drawer; relativelayout parentrl; relativelayout viewtoberemovedrl; view viewtobeadded;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     requestwindowfeature(window.feature_no_title);     setcontentview(r.layout.main_activity);     inflater = (layoutinflater)             .getsystemservice(context.layout_inflater_service);     drawer = (drawerlayout) findviewbyid(r.id.drawer_layout);     parentrl = (relativelayout) findviewbyid(r.id.parentrl);     viewtoberemovedrl = (relativelayout) findviewbyid(r.id.viewtobereplaced); }  public void onremoveview(view view) {     viewtobeadded = inflater.inflate(r.layout.add_view, null);     viewtoberemovedrl.setvisibility(view.gone);     parentrl.addview(viewtobeadded); }  public void onopendrawer(view view) {     drawer.opendrawer(parentrl); } } 

main_activity.xml

<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" >  <relativelayout     android:id="@+id/leftrl"     android:layout_width="match_parent"     android:layout_height="match_parent" >      <button         android:layout_width="wrap_content"         android:layout_height="75dp"         android:onclick="onopendrawer"         android:text="open drawer" /> </relativelayout>  <relativelayout     android:id="@+id/parentrl"     android:layout_width="290dp"     android:layout_height="match_parent"     android:layout_gravity="left" >      <relativelayout         android:id="@+id/viewtobereplaced"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:background="#ff0000" >          <button             android:layout_width="100dp"             android:layout_height="75dp"             android:onclick="onremoveview"             android:text="change view" />     </relativelayout> </relativelayout>  </android.support.v4.widget.drawerlayout> 

add_view.xml

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="290dp" android:layout_height="match_parent" android:orientation="vertical" android:background="#00ff00" >  <textview  android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margintop="100dp" android:text="new view" /> </relativelayout> 

usually when happens, drawer occupy entire screen height, it's default background colour of view clear.

set relativelayout@id/parentrl 's background solid colour or drawable, e.g.

android:background="@android:color/black" 

and drawer should cover entire screen height.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -