---
title: "Overlaying the Action Bar in Android App"  
description: "Previously, we have learn how to :  Add the action barAdding the Action Bars and Action Buttons in Android  Style the action barStyling the Action Bar"  
author: "Anonymous User"  
published: 2014-11-11  
updated: 2014-11-11  
canonical: https://www.mindstick.com/blog/699/overlaying-the-action-bar-in-android-app  
category: "android"  
tags: ["android", "android styles", "android layout"]  
reading_time: 3 minutes  

---

# Overlaying the Action Bar in Android App

Previously, we have learn how to :\

- Add the action bar (Adding the Action Bars and Action Buttons in [Android](https://www.mindstick.com/articles/13046/10-reasons-why-i-prefer-android-vs-iphone-ios))\
- Style the action bar (Styling the Action Bar in Android)\

Now we see how to overlay the action bar.

By [default](https://www.mindstick.com/interview/12771/what-is-the-importance-of-default-resources), the action bar appears at the top of [your activity](https://www.mindstick.com/interview/2585/where-will-you-declare-your-activity-so-the-system-can-access-it) window, slightly reducing the amount of space available for the rest of your activity's [layout](https://www.mindstick.com/articles/12853/android-layout-and-its-type). If, during the course of user [interaction](https://yourviews.mindstick.com/view/80771/technology-is-destroying-human-interaction-how), you want to hide and show the action bar, you can do so by calling hide() and show() on the ActionBar. However, this [causes](https://yourviews.mindstick.com/view/293/renovation-causes-wastage-of-resources) your activity to recompute and redraw the layout based on its new size.

To avoid resizing your layout when the action bar hides and shows, you can enable overlay mode for the action bar. When in overlay mode, your activity layout uses all the space available as if the action bar is not there and the [system](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) draws the action bar in [front of your](https://yourviews.mindstick.com/story/2347/conversations-should-never-make-in-front-of-your-kids) layout. This obscures some of the layout at the top, but now when the action bar hides or appears, the system does not need to resize your layout and the [transition](https://answers.mindstick.com/qa/94090/a-material-is-dimensionally-stable-at-room-temperature-if-its-glass-transition-temperature-tg-is) is seamless.

![Overlaying the Action Bar in Android App](https://www.mindstick.com/blogs/c78639d1-f06f-4536-b8f5-4e1d1e451834/images/b390e58c-13fb-4cce-ad15-cbf186184efa.png)

##### Enable Overlay Mode

To enable overlay mode for the action bar, you need to create a custom theme that extends an existing action bar theme and set the android:windowActionBarOverlay property to true

If your minSdkVersion is set to 11 or higher, your custom theme should use Theme.Holo theme (or one of its descendants) as your parent theme. For example:

```
<resources>   <!-- the theme applied to the application or activity -->   <style name="CustomActionBarTheme"           parent="@android:style/Theme.Holo">       <item name="android:windowActionBarOverlay">true</item>   </style></resources>
```

##### Specify Layout Top-margin

When the action bar is in overlay mode, it might obscure some of your layout that should remain visible. To ensure that such items remain below the action bar at all times, add either margin or padding to the top of the view(s) using the height specified by actionBarSize. For example:

```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingTop="?android:attr/actionBarSize">    ...
</RelativeLayout>
```

If you're using the Support Library for the action bar, you need to remove the android: prefix. For example:

```
<!-- Support library compatibility --><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:paddingTop="?attr/actionBarSize">    ...</RelativeLayout>
```

In this case, the ?attr/actionBarSize value without the prefix works on all versions, including Android 3.0 and higher.

This post is referred from Google docs Overlaying the Action Bar

---

Original Source: https://www.mindstick.com/blog/699/overlaying-the-action-bar-in-android-app

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
