android - How to get the new NavigationView to play nice with status bar scrim? -


i've been playing google's new design support library , it's blast! i'm little stumped though on navigation view. things read navigationview smart enough handle transparent scrim on own. (the android-developers post, one; search scrim). anyway, when tried following result:

transparent scrim

which great; want. except 1 thing. when drawer closed, scrim ugly dark grey, not primarycolordark . . .

enter image description here

here's layout:

<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" >  <android.support.design.widget.coordinatorlayout     android:layout_width="match_parent"     android:layout_height="match_parent"     android:fitssystemwindows="true">      <linearlayout         android:id="@+id/linear_layout"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:orientation="vertical">          <include layout="@layout/toolbar" />          <fragment             android:id="@+id/fragment"             android:name="com.gmail.rixx.justin.envelopebudget.homefragment"             android:layout_width="match_parent"             android:layout_height="wrap_content"             tools:layout="@layout/fragment_home" />      </linearlayout>      <android.support.design.widget.floatingactionbutton         android:id="@+id/fab"         android:layout_height="wrap_content"         android:layout_width="wrap_content"         android:layout_gravity="end|bottom"         android:layout_margin="@dimen/fab_margin"         app:backgroundtint="@color/accent"         android:src="@drawable/ic_add_white_24dp" />  </android.support.design.widget.coordinatorlayout>  <android.support.design.widget.navigationview     android:layout_width="wrap_content"     android:layout_height="match_parent"     android:layout_gravity="start"     app:headerlayout="@layout/drawer_header"     app:menu="@menu/drawer" />  </android.support.v4.widget.drawerlayout> 

the activity code:

public class home extends actionbaractivity {      private toolbar mtoolbar;     private drawerlayout mdrawerlayout;     private context mcontext = this;      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_home);          setuptoolbar();         setupnavdrawer();          findviewbyid(r.id.fab).setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 startactivity(new intent(mcontext, newtransactionactivity.class));             }         });     }      private void setuptoolbar() {         mtoolbar = (toolbar) findviewbyid(r.id.toolbar);         if (mtoolbar != null) {             setsupportactionbar(mtoolbar);         }     }      private void setupnavdrawer() {         if (mtoolbar != null) {             mdrawerlayout = (drawerlayout)     findviewbyid(r.id.drawer_layout);              getsupportactionbar().setdisplayhomeasupenabled(true);             mtoolbar.setnavigationicon(r.drawable.ic_menu_white_24dp);             mtoolbar.setnavigationonclicklistener(new view.onclicklistener() {                 @override                 public void onclick(view v) {                     mdrawerlayout.opendrawer(gravitycompat.start);                 }             });         }     }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.menu_home, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle action bar item clicks here. action bar         // automatically handle clicks on home/up button, long         // specify parent activity in androidmanifest.xml.         int id = item.getitemid();          //noinspection simplifiableifstatement         if (id == r.id.action_settings) {             return true;         }          return super.onoptionsitemselected(item);     } } 

and v21/styles:

<?xml version="1.0" encoding="utf-8"?> <resources>     <style name="apptheme" parent="apptheme.base">         <item name="android:colorprimary">@color/primary</item>         <item name="android:colorprimarydark">@color/primary_dark</item>         <item name="android:coloraccent">@color/accent</item>         <item name="android:textcolorprimary">@color/primary_text</item>         <item name="android:textcolorsecondary">@color/secondary_text</item>          <item name="android:windowdrawssystembarbackgrounds">true</item>         <item name="android:statusbarcolor">@android:color/transparent</item>      </style> </resources> 

i modeled after chris banes's cheesesquare app on github i'm not getting behavior want.

i've tried removing windowdrawssystembarbackgrounds , statusbarcolor v21/styles, , proper color, status bar never goes transparent:

enter image description here

help appreciated. new stuff, know we're learning.

thanks reading!

-justin

after struggling several more hours, , copiously comparing code cheesesquare app, found following: drawerlayout must have attribute android:fitssystemwindows="true", , navigationview well, coordinatorlayout should not. once made changes, worked.

thanks all, , helpful somebody!

you can @ code layout here.

-justin


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -