I have tried many ways to make action bar place in bottom of status bar but still not working, I am using API 17,I have added android:fitsSystemWindows="true" in CoordinatorLayout but still not working
Here is my code:
the main_activity:
<net.aparteman.apartemanapp.viewHolder.SlidingMenuLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.NavigationView
android:id="#+id/nvView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#color/dark_purple"
android:fitsSystemWindows="true"
android:layoutDirection="rtl"
android:textDirection="rtl"
app:elevation="0dp"
app:headerLayout="#layout/dashboard_nav_header"
app:itemTextColor="#color/white"
app:menu="#menu/dashboard_drawer_view"
app:theme="#style/ApartemanStyle" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<include
android:id="#+id/actionbar"
layout="#layout/dashboard_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#+id/dashboard_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
the dashboard_bar.xml :
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
app:popupTheme="#style/AppTheme" />
</android.support.design.widget.AppBarLayout>
style.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="ApartemanStyle" parent="Theme.AppCompat.Light">
<item name="android:textSize">16sp</item>
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
<item name="contentInsetStart">0dp</item>
<item name="contentInsetEnd">0dp</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="ApartemanStyle.NoActionBar">
<item name="actionMenuTextColor">#color/white</item>
<item name="android:actionMenuTextColor">#color/white</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="ApartemanStyle.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="ApartemanStyle.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
It looks like this:
Can anyone help me on this?
Related
When the layout forms everything is fine, as in image is formed from status bar and status bar color is transparent. But whenever i scroll up and then scroll down the recycler view the image is scrolled till under status bar. But when i click on the image, it takes the original position.
Code for style/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>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" >
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
</style>
Code for collapsing toolbar layout.
<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="com.ashish.swipemusic.GenreDetails">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="#dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways|exitUntilCollapsed">
<ImageView
android:id="#+id/headerArtist"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="fitXY"
android:src="#drawable/album_details1"
/>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways|exitUntilCollapsed"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_genre_details" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/fab_margin"
android:src="#drawable/ic_play_arrow_black_24dp"
app:layout_anchor="#id/app_bar"
app:layout_anchorGravity="bottom|end" />
<android.support.v7.widget.RecyclerView
android:id="#+id/genre_songs_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
>
</android.support.v7.widget.RecyclerView>
before scroll
after scroll down status bar appears
Did you try removing app:layout_scrollFlags="scroll|enterAlways|exitUntilCollapsed" inside your Toolbar? I've tried this way and it works pretty well
I'm trying to use Tablayout with Toolbar but it's giving me like the image below, and when try to remove <item name="android:fitsSystemWindows">true</item> from v21\styles.xml the Toolbar being overlapped by the android system status bar
v21\styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="MyMaterialTheme.Base">
<!-- Customize your theme here. -->
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:typeface">serif</item>
<item name="android:fitsSystemWindows">true</item>
</style>
<style name="ToolBarStyle" parent="AppTheme">
<item name="colorControlNormal">#android:color/white</item>
</style>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="MyMaterialTheme.Base">
<!-- Customize your theme here. -->
</style>
<style name="MyMaterialTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:typeface">serif</item>
</style>
<style name="ToolBarStyle" parent="AppTheme">
<item name="colorControlNormal">#android:color/white</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="PopupTheme" parent="Theme.AppCompat">
<item name="android:background">#color/popColorBg</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:drawSelectorOnTop">true</item>
</style>
activity.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fab="http://schemas.android.com/tools"
>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMaxWidth="0dp"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<com.melnykov.fab.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="#drawable/ic_add_white_24dp"
fab:fab_colorNormal="#color/colorPrimaryFab"
fab:fab_colorPressed="#color/colorPrimaryDarkFab"
fab:fab_colorRipple="#color/colorPrimaryDarkFab" />
And according to this Answer if I'll do this and remove android:fitsSystemWindows="true" from v21\styles.xml my layout will be like this:
I am stuck in my own code. I can't find where to set the color of the "Title" text, in the navigationDrawer, to the defualt gray.
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:background="#000"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/header"
app:itemTextColor="your color"
app:menu="#menu/drawer" />
app:itemTextColor="your color" only changes each item, like Import, Gallery etc. But how to change the Communicate textColor with the line above?
Picture 2 (dark blue) is what it looks like in my project. I managed to "somewhere" set the color to white in my project.
Can you find my problem? Currently my "Title" text is white..
nav_header_main.xml
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:src="#android:drawable/sym_def_app_icon"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:textColor="#color/whiteGray"
android:text="#string/app_name"
/>
</LinearLayout>
activity_main.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" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:background="#color/nav_drawer_background"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="#menu/activity_main_drawer"
app:headerLayout="#layout/nav_header_main"
app:itemTextColor="#color/nav_drawer_text" />
<android.support.design.widget.NavigationView
android:id="#+id/nav_right_view"
android:background="#color/nav_drawer_background"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:fitsSystemWindows="true"
app:menu="#menu/activity_main_right_drawer"
app:itemTextColor="#color/nav_drawer_text" />
</android.support.v4.widget.DrawerLayout>
app_bar_main.xml
<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"
app:popupTheme="#style/AppTheme.PopupOverlay"
/>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
<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"
/>
values/style.xml
<style name="WelcomeDialogTitle">
<item name="android:gravity">center_horizontal</item>
</style>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowBackground">#color/darkblue</item>
<item name="colorPrimary">#color/transparent</item>
<item name="colorPrimaryDark">#color/darkblue</item>
<item name="colorAccent">#color/darkblue</item>
</style>
<style name="AppTheme.NoActionBar" parent="#style/Theme.AppCompat">
<item name="android:windowBackground">#color/darkblue</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="colorPrimary">#color/transparent</item>
<item name="colorPrimaryDark">#color/transparent</item>
<item name="colorAccent">#color/transparent</item>
</style>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:windowActionBarOverlay">true</item>
<item name="windowActionBarOverlay">true</item>
</style>
<style name="CustomTheme" parent="#android:style/Theme.Black">
<item name="android:listViewStyle">#style/CustomListView</item>
<item name="android:textViewStyle">#style/CustomTextView</item>
</style>
<style name="CustomListView" parent="#android:style/Widget.ListView">
<item name="android:textColor">#000000</item>
<item name="android:fastScrollEnabled">true</item>
</style>
<style name="CustomTextView" parent="#android:style/Widget.TextView">
<item name="android:textColor">#000000</item>
<item name="android:textSize">17sp</item>
<item name="android:padding">1dp</item>
</style>
<style name="TitleTextStyleLarge">
<item name="android:gravity">left|center</item>
<item name="android:shadowColor">#color/white</item>
<item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
<item name="android:textColor">#color/white</item>
<item name="android:textSize">18sp</item>
</style>
<style name="TitleTextStyle">
<item name="android:gravity">left|center</item>
<item name="android:textSize">18sp</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_marginLeft">5dp</item>
<item name="android:layout_weight">1</item>
<!-- <item name="android:shadowColor">#color/white</item> -->
<item name="android:textColor">#color/white</item>
</style>
<style name="BarTitleStyle">
<item name="android:background">#drawable/bg_list_topbar</item>
<item name="android:layout_height">33dp</item>
<!-- <item name="android:shadowColor">#color/white</item> -->
<item name="android:layout_width">fill_parent</item>
</style>
<style name="BarTitleProgressStyle">
<item name="android:background">#drawable/bg_list_topbar</item>
<item name="android:layout_height">27dp</item>
<item name="android:layout_width">27dp</item>
<item name="android:layout_marginBottom">1dp</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:layout_marginTop">1dp</item>
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center_vertical|center_horizontal</item>
</style>
</resources>
My activity theme
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar"
>
<meta-data
drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
<item
android:id="#+id/nav_search"
android:title="#string/LabelSearchTabTitle" />
<item
android:id="#+id/nav_wiki"
android:title="#string/LabelTitleWikiBook" />
<item
android:id="#+id/nav_forum"
android:title="#string/LabelTitleForum"
/>
<item
android:id="#+id/nav_history"
android:title="#string/LabelHistory"
/>
<item
android:id="#+id/nav_favs"
android:title="#string/LabelFavourites"
/>
</group>
<item android:title="#string/LabelTitleSupportPages">
<menu>
<item
android:id="#+id/nav_options"
android:title="#string/LabelTitleSettings" />
<item
android:id="#+id/nav_qa"
android:title="#string/LabelTitleAbout" />
<item
android:id="#+id/nav_facebook"
android:title="#string/LabelTitleFB" />
</menu>
</item>
</menu>
Try :
<item name="android:textColorSecondary">#eeeeee</item>
Edit :
Replace :
<style name="AppTheme.NoActionBar" parent="#style/Theme.AppCompat">
<item name="android:windowBackground">#color/darkblue</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
With This :
<style name="AppTheme.NoActionBar" parent="#style/Theme.AppCompat">
<item name="android:windowBackground">#color/darkblue</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:textColorSecondary">#eeeeee</item>
</style>
Edit 2 :
<style name="AppTheme.NoActionBar" parent="#style/Theme.AppCompat">
<item name="android:windowBackground">#color/darkblue</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
// change header color
<item name="android:textColorSecondary">#eeeeee</item>
// change separator color
<item name="android:listDivider">#ff000000</item>
</style>
You can make a custom layout for your Drawer items and include the custom layout in NavigationView.. Like this
<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">
<include
layout="#layout/sidedrawer"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
</android.support.design.widget.NavigationView>
sidedrawer is your custom layout and you can provide it any style or color you want.. hope it will help you
I switched from the normal Light Dark appcompat themes to DayNight and now the status bar color is being drawn over my window. What changed to break my configuration?
styles.xml
<style name="AppThemeDayNight" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primary_dark</item>
<item name="colorAccent">#color/accent</item>
<item name="preferenceTheme">#style/PreferenceThemeOverlay</item>
<item name="statusViewStyle">#style/StatusViewStyle</item>
</style>
<style name="AppThemeDayNight.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" />
styles-v21.xml
<style name="AppThemeDayNight.NoActionBar">
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<!--<item name="android:statusBarColor">#android:color/transparent</item> -->
<!--<item name="android:windowTranslucentStatus">true</item> -->
<item name="android:windowActionModeOverlay">true</item>
</style>
<style name="AppThemeDayNight.NoActionBar.Drawer">
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
activity_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="#+id/coordinator_layout"
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">
<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"
tools:title="Timeline"/>
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_twitter" />
<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"
app:srcCompat="#drawable/ic_menu_send" />
</android.support.design.widget.CoordinatorLayout>
<!-- The navigation drawer -->
<android.support.design.widget.NavigationView
android:id="#+id/navigation"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="#menu/activity_main_drawer" />
Here's a screenshot of the drawer open with the navigation view, which should be drawing over the status bar.
add
<item name="android:windowContentOverlay">#null</item>
to
<style name="AppThemeDayNight" parent="Theme.AppCompat.DayNight.NoActionBar">
block and try
Try set the windowTranslucentStatus to true
<item name="android:windowTranslucentStatus">true</item>
In Lollipop, The background color of toolbar was shown normally, but in KitKat, it was shown as white color.
I don't know why.
activity_main.xml
<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.support.design.widget.CoordinatorLayout>
styles.xml
<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/colorPrimaryDark</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>
styles.xml-v21
<resources>
<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>
</resources>
Try putting your AppBarLayout at the end of you code. Apparently your included layout is overlapping the ToolBar. That happened to me and I fixed it doing that, it just came to my mind. Like this:
<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">
<include layout="#layout/content_main"/>
<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>
</android.support.design.widget.CoordinatorLayout>
Create a base theme in styles.xml with primary colors and other colors colors then set it as parent in styles.xml-v21 for your style name="AppTheme.NoActionBar".
Below is my example :
in styles.xml
<style name="AppBase" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary_color</item>
<item name="colorPrimaryDark">#color/primary_color_dark</item>
<item name="colorAccent">#color/primary_yellow_bright</item>
<item name="colorControlNormal">#color/primary_yellow</item>
<item name="colorControlHighlight">#color/primary_color_light_100</item>
<item name="colorControlActivated">#color/primary_yellow_bright</item>
<item name="colorButtonNormal">#color/primary_yellow_bright</item>
<item name="android:windowBackground">#color/primary_white</item>
<item name="android:textColorPrimary">#color/primary_color</item>
<item name="android:textColorSecondary">#color/primary_color_light</item>
<item name="android:textColor">#color/primary_white</item>
<item name="android:buttonStyle">#style/ButtonAppTheme</item>
</style>
<style name="AppTheme" parent="AppBase" />
in styles.xml-v21
<style name="AppTheme" parent="AppBase">
<item name="android:navigationBarColor">#color/primary_light_gray</item>
<item name="android:windowContentTransitions">true</item>
<item name="android:windowAllowEnterTransitionOverlap">true</item>
<item name="android:windowAllowReturnTransitionOverlap">true</item>
<item name="android:windowSharedElementEnterTransition">#android:transition/move</item>
<item name="android:windowSharedElementExitTransition">#android:transition/move</item>
</style>
in AndroidManifest.xml
android:theme="#style/AppTheme"
should work.