I'm creating an android app for our capstone project. I'm using API 23. I add elevation on my toolbars and other components yet the shadows aren't appearing. Is my theme ruining it?
<!-- Base application theme. -->
<style name="ThesisTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- 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:colorButtonNormal">#color/colorButton</item>
<item name="android:textColorPrimary">#color/textColorPrimary</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
<item name="android:navigationBarColor">#color/colorPrimary</item>
<item name="colorControlNormal">#c5c5c5</item>
<item name="colorControlActivated">#color/colorAccent</item>
<item name="colorControlHighlight">#color/colorPrimaryDark</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<!--Datepicker-->
<item name="android:datePickerDialogTheme">#style/MyDatePickerDialogTheme</item>
</style>
when i try to include the toolbar then run the program to my phone/ emulator the shadow wont display. even with cardview
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/activity_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="capstoreit.capstoreit.Login.Login"
android:background="#drawable/login_bg">
<!--Layout for Login and Signup-->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:elevation="10dp"
android:layout_height="wrap_content">
<!--Toolbar-->
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="#+id/login_toolbar"
android:layout_width="match_parent"
android:elevation="10dp"
local:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/new_logo"
android:adjustViewBounds="true"
android:padding="5dp"
android:id="#+id/app_logo" />
</android.support.v7.widget.Toolbar>
<!--Tab-->
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="fixed"
app:tabGravity="fill"
android:elevation="10dp"
android:background="#color/textColorPrimary"
app:tabSelectedTextColor="#color/colorAccent"
/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.8"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_alignParentStart="true"
>
</android.support.v4.view.ViewPager>
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="0.2"
/>
</LinearLayout>
</RelativeLayout>
Screenshot:
After changing to app:elevation
I was able to fix my erro by removing this on my Android Manifest:
android:hardwareAccelerated="false"
use this if you are using support library for older versions too
app:elevation
use this if you are not using support library
android:elevation
Related
I have a tab layout and each tab is represented my a fragment in the viewpager. Now I tried to attach a Toolbar to the bottom but the android navigation bar keeps overlapping it. Adding a margin is not a option because it looks very strange on devices without a navigation bar on the screen.
XML from main activity:
<?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:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/appbar_padding_top"
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:layout_weight="1"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:title="#string/app_name">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TabItem
android:id="#+id/tabItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/fragment_map_title" />
<android.support.design.widget.TabItem
android:id="#+id/tabItem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/fragment_list_title" />
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
XML from fragment:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.google.android.gms.maps.MapView
android:id="#+id/mapView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/ballon_info_bar" />
<android.support.v7.widget.Toolbar
android:background="#2a3b4c"
android:id="#+id/ballon_info_bar"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="20dp">
</android.support.v7.widget.Toolbar>
</RelativeLayout>
Style 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>
<item name="android:windowTranslucentNavigation">true</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>
I found several other posts about this topic but none of them solved my problem.
EDIT1: The margin in the image is just for visualization.
EDIT2: According to the blueprint, the ViewPager is alredy behind the navigationbar
The solution is:
Setting android:fitsSystemWindows to false and setting android:windowTranslucentNavigation to false in style.xml
I am trying to make a translucent search activity with variable height - wrap content on RecyclerView to be exact. Unfortunately, I am not able to fit screen height and end up with weird margin at the bottom, as seen on screenshot.
Here is my activity layout
<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="wrap_content">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:theme="#style/WeatherTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
style="#style/AppBarStyle.Main"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:logo="#null" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="#+id/suggestionsContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:visibility="gone" />
<TextView
android:id="#+id/emptyResults"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:padding="16dp"
android:text="#string/not_found"
android:textSize="22sp"
android:visibility="gone" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white">
<ProgressBar
android:id="#+id/loading"
android:layout_width="26dp"
android:layout_height="26dp"
android:layout_gravity="center"
android:background="#color/white"
android:layout_margin="14dp"
android:visibility="gone" />
</FrameLayout>
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
And theme used for this activity is MainTheme.NoActionBar.Search
<style name="MainTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">#color/theme_color_primary</item>
<item name="colorPrimaryDark">#color/theme_color_primary_dark</item>
<item name="colorAccent">#color/theme_color_accent</item>
<item name="colorControlHighlight">#color/theme_color_highlight</item>
<item name="android:textColorPrimary">#color/theme_text_color_primary</item>
<item name="android:windowBackground">#color/theme_color_background</item>
</style>
<style name="MainTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="MainTheme.NoActionBar.Search" >
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.5</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
</style>
Will appreciate any hints on what might cause the problem!
In my app contet is hidden under appbarlayout. I don't expect that behaviour!
Android 23 PREVIEW
ANDROID 21 - test on DEVICE
ANDROID 21 - test on DEVICE content hidden under toolbar
Altough my content scroll down as expect, when it goes up content is hidden under toolbar. I uploaded also android 23 preview because there is visible that actually toolbar is align Top behind status bar. Working on device content go up where is should be moved if the preview was correct. But toolbar view is under status bar not behind. I dont know where is the problem.
Style
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#color/colorPrimaryDark</item>
</style>
<style name="AppTheme.NoStatusBar" parent="AppTheme.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="windowActionBarOverlay">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
UPDATED
ok I found the solution. It was so dump. Just my scrollView was scrolled down due to its last child which was gaining focus - recycler view.
No I set on cardView focusableInTouchMode="true" and the last element on false
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:fitsSystemWindows="true"
android:fillViewport="true">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="4dp"
android:layout_margin="4dp"
app:contentPaddingTop="24dp"
android:focusableInTouchMode="true"/>
...
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_overbid_history"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="200dp"
android:focusable="false"
android:focusableInTouchMode="false"/>
android.support.v4.widget.NestedScrollView>
I'm sharing part of my code with you, it's working for me in my app:
<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"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="240dp"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:expandedTitleMarginBottom="140dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.75">
<ImageView
android:id="#+id/store_detail_background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
...
</FrameLayout>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<FrameLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
v21/styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#color/...</item>
<item name="windowActionModeOverlay">true</item>
...
</style>
Actually i am trying to do navigation drawer but i want it on status bar not below it i put all kind of code to make it transparent but still don't work
My xml layout is like
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:elevation="7dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/actionbar_color"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp"></android.support.v7.widget.Toolbar>
<FrameLayout
android:id="#+id/content_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="#+id/drawer_Linearlayout"
android:layout_width="260dp"
android:layout_gravity="start|top"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="168dp"
android:scaleType="fitXY"
android:src="#drawable/navigation_img"
android:id="#+id/mytext"/>
<ListView
android:id="#+id/navdrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:layout_below="#+id/mytext"
android:layout_gravity="start|bottom"
android:background="#FFFFFF"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="#drawable/list_selector"
android:paddingTop="5dp"></ListView>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
My Theme is for v-21
<style name="AppThemes" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowTranslucentStatus">true</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="colorPrimary">#color/actionbar_color</item>
<item name="colorPrimaryDark">#color/alert_normal</item>
<item name="colorAccent">#color/actionbar_color</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
When i remove LinearLayout and ImageView it work fine but
i want imageview inside DrawerLayout but actually it supports only 2 child elements so i have to use LinearLayout
Please suggest me way to do that way.
I got solution for such layout.
Sorry for posting late. I just have to make a little change in xml just like that.
<?xml version="1.0" encoding="utf-8"?>
<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"
android:elevation="7dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="#layout/app_bar"></include>
<FrameLayout
android:id="#+id/content_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:id="#+id/drawer_Linearlayout"
android:layout_width="260dp"
android:layout_gravity="left|start"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="168dp"
android:scaleType="fitXY"
android:src="#drawable/navigation_img"
android:id="#+id/mytext" />
<ListView
android:id="#+id/navdrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:layout_below="#+id/mytext"
android:layout_gravity="start|bottom"
android:background="#FFFFFF"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="#drawable/list_selector"
android:paddingTop="5dp"></ListView>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
And also make your theme style for v-21 like that.
<!-- Base application theme. -->
<style name="AppThemes" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:windowTranslucentStatus">true</item>
<item name="colorPrimary">#color/actionbar_color</item>
<item name="android:textColor">#color/myNavigationColor</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="titleTextStyle">#style/ActionBarTitleText</item>
<item name="colorPrimaryDark">#color/actionbar_primary_color</item>
<item name="colorAccent">#color/actionbar_color</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="android:actionOverflowButtonStyle">#style/MyActionButtonOverflow</item>
</style>
and normal theme style is like
<style name="AppThemes" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimaryDark">#color/actionbar_primary_color</item>
<item name="colorPrimary">#color/actionbar_color</item>
<item name="windowActionModeOverlay">true</item>
<item name="android:textColor">#color/myNavigationColor</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="android:actionOverflowButtonStyle">#style/MyActionButtonOverflow</item>
</style>
Hope if you get stuck in such situation, these will be the solution for you.
Try adding these lines to your android:id="#+id/drawer_Linearlayout"
The layout gravity should start from left to right, and make it fit by setting the android:fitsSystemWindowsattribute to true.
<LinearLayout
android:id="#+id/drawer_Linearlayout"
android:layout_width="260dp"
android:layout_gravity="left|start"
android:fitsSystemWindows="true"
android:layout_height="match_parent"
android:orientation="vertical">
I'm trying to use Toolbar instead of ActionBar. In Android 5.0.+ it works but in 4.4 the status bar is placed on top of the Toolbar.
Screenshot:
Layout:
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:background="#color/actionbar_color"/>
Adding Toolbar in OnCreate():
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
Full layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/drawer_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
android:background="#color/actionbar_color"/>
<com.astuetz.PagerSlidingTabStrip
android:id="#+id/tabs"
android:textColor="#android:color/white"
android:layout_width="match_parent"
android:layout_height="48dip"
android:background="#color/actionbar_color" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/colors"
android:layout_below="#+id/tabs"/>
</LinearLayout>
<LinearLayout
android:id="#+id/left_drawer"
style="#style/drawer_list"
android:fitsSystemWindows="true"
android:orientation="vertical">
<ListView
android:id="#+id/mainMenu"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="match_parent"
android:divider="#android:color/transparent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
Add a frameLayout and in its height use #dimen/statusBarHeight. Then you can create an attrs.xml file for each version (normal, v19 and v21). Inside of each attrs.xml put <dimen name="statusBarHeight">25dp</dimen>
Change 25dp to 0 in normal, 25 in v19 and 0 in v21. You can create attrs.xml for landscape mode too (values-land, values-land-v19, etc).
<FrameLayout
android:id="#+id/statusBar"
android:layout_width="match_parent"
android:layout_height="#dimen/statusBarHeight"
android:background="?colorPrimaryDark"
android:translationZ="4dp" />
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
Take a look this link: Github
For Kitkat add:
android:fitsSystemWindows="true"
Tutorial: http://www.viralandroid.com/2015/08/android-toolbar-example.html
Add in your XML layout
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:minHeight="?attr/actionBarSize"
android:background="#2196F3"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.Toolbar>
In Java
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
activity_main.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="com.azim.innovation.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.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_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
content_main.xml
<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.azim.innovation.MainActivity"
tools:showIn="#layout/activity_main">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
</RelativeLayout>
Colors
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
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/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" />
Styles-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>
Dependency
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
Try using the ThemeOverlay.NoActionBar theme. It dosen't add the Action Bar
Did you change the theme in styles.xml.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
If you are using a toolbar it should be NoActionBar in the theme.
Source: Android Toolbar Example.