Android: how to remove a line between a toolbar and a status bar

I'm interested in having a uniform color toolbar and status bar. If I provide colorPrimary and colorPrimaryDark as the same color, this should be possible. I get the desired result with the ActionBar, but not with the toolbar. I also create a navigation view, so I need the status bar to be transparent.

Using the toolbar Using ActionBar

Code: Styles-v21

 <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> <item name="android:windowDrawsSystemBarBackgrounds">true</item> <item name="android:statusBarColor">@android:color/transparent</item> </style> 

Code: Styles

 <resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimary</item> <item name="colorAccent">@color/colorAccent</item> </style> <style name="AppTheme.NoActionBar"> <item name="windowActionBar">false</item> <item name="windowNoTitle">true</item> </style> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/> </resources> 

Steps to play:

  • Create a new project in Android Studio using Navigation Drawer Activity
  • Set primary and primaryDark as the same colors
  • Run on a device or emulator
+6
source share
2 answers

The only solution I could come up with was to remove android:fitsSystemWindows="True" from the coordinators layout

edit: Another solution is to transfer the coordinator layout to another coordinator format.

 <?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"> <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay" app:layout_scrollFlags="scroll|enterAlways"> <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" app:layout_behavior="@string/appbar_scrolling_view_behavior"/> </android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout> 

Front enter image description here

After enter image description here

+7
source

This shadow that you see is an overlay of the contents of the window, you can remove it:

Add this line to your topic:

<item name="android:windowContentOverlay">@null</item>

0
source

All Articles