An example of how to extend the ActionBar under the status bar from the theme

Overview

Extended ActionBar

The problem:

Android 4.4 Kitkat introduced a wonderful new opportunity: translucent bars.

It's as simple as adding the following to your theme:

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>

Awesome, right? Well, almost.
The thing is, if you happen to have an ActionBar (like 99.9% of apps out there) than it won't automatically extend behind the status bar: the status bar will be translucent and the window background will be showed...
A picture is worth a thousand words:

Image

There are many ways to fix this programmatically or with some wise layouts, but when the application is launched or recreated only the theme will be used (before loading ANY code or layout) and the problem will still be annoyingly present.

The solution:

In this repository I show how to achieve an illusion of "ActionBar extension" (look at the code to see what it means). It is unfortunately more of a hack than a proper solution, but that is due to the fact that the required components (namely @android:dimen/status_bar_height and the ability to create custom drawables, as the ones provided are barely usable and highly bugged) have been banned by the Gods.

Please use it with careful consideration and don't blame me if your device explodes or you cat conquers the world!

Image

The extra mile:

While I was there I took the opportunity to create a simple Activity that removes the hacky window background and does things properly in order to eliminate any overdraw.
It's supposed to be a starting point, though I hope to make it into a real library someday.

Before:

Image

After:

Image

Notes:

I will start using a variation of this code in my apps along with a "secret agent" that will notify me if it ever encounters a device with a status bar bigger than 25dp (if it's smaller or not at the top, it won't be a problem as it will get drawn behind the ActionBar).
If such a thing happens, I will update this accordingly.

You might also like...
An Android Library to help you create actionbar tabs like
An Android Library to help you create actionbar tabs like "Capitaine train" app by Cyril Mottier

TabBarView An Android Library to help you create actionbar tabs like "Capitaine train" app by Cyril Mottier Implementation: Declare TabBarView and set

This library offers a simple method to add a small badge icon to your ActionBar-MenuItem
This library offers a simple method to add a small badge icon to your ActionBar-MenuItem

Android-ActionItemBadge ActionItemBadge is a library which offers a simple and easy to use method to add a badge to your action item! Screenshots Incl

NTabLayout is a simple tab bar custom view under android which has click-sliding and scaling up animation effect.
NTabLayout is a simple tab bar custom view under android which has click-sliding and scaling up animation effect.

NTabLayout Brief NTabLayout is a simple tab bar custom view under android which has click-sliding and scaling up animation effect. This tab bar's effe

A util for setting status bar style on Android App.
A util for setting status bar style on Android App.

StatusBarUtil A util for setting status bar style on Android App. It can work above API 19(KitKat 4.4). 中文版点我 Sample Download StatusBarUtil-Demo Chang

Tidy up your Android status bar before taking screenshots for the Play Store
Tidy up your Android status bar before taking screenshots for the Play Store

DEPRECATED This project no longer works on recent versions of Android. Use Android's build-in Demo mode instead. For the curious, more information abo

A util for setting status bar style on Android App.
A util for setting status bar style on Android App.

StatusBarUtil A util for setting status bar style on Android App. It can work above API 19(KitKat 4.4). 中文版点我 Sample Download StatusBarUtil-Demo Chang

Android图表库(XCL-Charts is a free charting library for Android platform.),基于Android Canvas来绘制各种图表,使用简便,定制灵活。目前支持3D/非3D/背向式/横向/竖向柱形图(Bar Chart)、3D/非3D饼图(Pie Chart)、堆叠图(Stacked Bar Chart)、面积图(Area Chart)、 折线图(Line Chart)、曲线图(Spline Chart)、环形图(Dount Chart)、南丁格尔玫瑰图(Rose Chart)、仪表盘(Dial Chart)、刻度盘(Gauge Chart)、雷达图(Radar Chart)、漏斗图(Funnel Chart)、圆形图(Circle Chart)、弧线比较图、散点图(Scatter Chart)、气泡图(Bubble Chart)、范围条形图(RangeBar Chart)等图表。其它特性还包括支持图表缩放、手势移动、点击响应、动画效果、多轴显示、图表参考线、混合图表及同数据源不同图表类型切换等。 IOSProgressBar is a progress-bar lib for android. And the progress-bar looks like iOS system style
IOSProgressBar is a progress-bar lib for android. And the progress-bar looks like iOS system style

IOSProgressBar is a progress-bar lib for android. And the progress-bar looks like iOS system style

This directory contains the model files (protos) for the Bar ServiceThis directory contains the model files (protos) for the Bar Service
This directory contains the model files (protos) for the Bar ServiceThis directory contains the model files (protos) for the Bar Service

This directory contains the model files (protos) for the Bar ServiceThis directory contains the model files (protos) for the Bar Service

Bottom-App-Bar-with-Bottom-Navigation-in-Jetpack-compose-Android - Bottom App Bar with Bottom Navigation in Jetpack compose
Bottom-App-Bar-with-Bottom-Navigation-in-Jetpack-compose-Android - Bottom App Bar with Bottom Navigation in Jetpack compose

Bottom-App-Bar-with-Bottom-Navigation-in-Jetpack-compose-Android This is simple

This project under develop

Asynchronous Http Client for Android An asynchronous, callback-based Http client for Android built on top of Apache's HttpClient libraries. Changelog

A surgical debugging tool to uncover the layers under your app.
A surgical debugging tool to uncover the layers under your app.

Scalpel DEPRECATED! Android Studio 4.0's layout inspector now includes a live-updating 3D view. Use it! A surgical debugging tool to uncover the layer

Under the Hood is a flexible and powerful Android debug view library. It uses a modular template system that can be easily extended to your needs, although coming with many useful elements built-in.
Under the Hood is a flexible and powerful Android debug view library. It uses a modular template system that can be easily extended to your needs, although coming with many useful elements built-in.

Under the Hood - Android App Debug View Library Under the Hood is a flexible and powerful Android debug view library. It uses a modular template syste

This project under develop

Asynchronous Http Client for Android An asynchronous, callback-based Http client for Android built on top of Apache's HttpClient libraries. Changelog

A surgical debugging tool to uncover the layers under your app.
A surgical debugging tool to uncover the layers under your app.

Scalpel DEPRECATED! Android Studio 4.0's layout inspector now includes a live-updating 3D view. Use it! A surgical debugging tool to uncover the layer

Android ProgressBar that
Android ProgressBar that "bends" under its own weight. Inspired by http://drbl.in/nwih

RopeProgressBar Android ProgressBar that "bends" under its own weight. Attributes Attribute Type Default Usage app:ropeMax integer 0 The max value of

An under development minecraft plugin (1.8.8) to learning Kotlin language

CorePlus CorePlus is a minecraft plugin coded with Kotlin language. Still under development CorePlus will be an essential for each minecraft servers !

This prototype app provides a list of events to be held under an organization (school, college, club, etc.) and the users can manually set event reminders at their scheduled time so that they do not miss an event.

E-CELL NITS Sample App This prototype app provides a list of events to be held under E-Cell NIT Silchar (for example, Srijan 2.0) and the users can ma

🎨 Modern image loading library for Android. Simple by design, powerful under the hood.
🎨 Modern image loading library for Android. Simple by design, powerful under the hood.

Simple Image Loader Modern image loading library for Android. Simple by design, powerful under the hood. Kotlin: Simple Image Loader is Kotlin-native

Owner
Eugenio Marletti
Eugenio Marletti
News Stand app makes the ActionBar not boring!

No boring ActionBar http://flavienlaurent.com/blog/2013/11/20/making-your-action-bar-not-boring/ An explaination on how to implement the edition scree

Flavien Laurent 1.7k Oct 7, 2022
An Android Library to help you create actionbar tabs like "Capitaine train" app by Cyril Mottier

TabBarView An Android Library to help you create actionbar tabs like "Capitaine train" app by Cyril Mottier Implementation: Declare TabBarView and set

Mirko Dimartino 510 Nov 15, 2022
Android library implementing a fading effect for the action bar, similar to the one found in the Play Music app

FadingActionBar FadingActionBar is a library which implements the cool fading action bar effect that can be seen in the new Play Music app. This libra

Manuel Peinado Gallego 2.9k Nov 21, 2022
Android - a library that adds a glass-like effect to the action bar.

GlassActionBar GlassActionBar is an Android library which implements a glass-like effect for the action bar. The three most commonly used action bar i

Manuel Peinado Gallego 1.2k Nov 20, 2022
A flexible theme provider for Jetpack Compose. Supports dynamic theme changes and saving theme preference.

JetTheme JetTheme is a flexible theme provider for Jetpack Compose. Change the theme and recompose the UI dynamically. Save theme preference to local

Mao Yufeng 48 Oct 19, 2022
SystemUiController - Android Ui color controller (status bar, navigation bar)

SystemUiController Android system ui color controller (status bar, navigation bar) Download implementation "land.sungbin:systemuicontroller:${version}

Ji Sungbin 8 Dec 3, 2022
[] Action bar implementation which uses the native action bar on Android 4.0+ and a custom implementation on pre-4.0 through a single API and theme.

DEPRECATED ActionBarSherlock is deprecated. No more development will be taking place. For an up-to-date action bar backport use AppCompat. Thanks for

Jake Wharton 7.1k Dec 24, 2022
Extend From VLayout, and it will support Android X

XVLayout Extend From VLayout, and it will support Android X 从VLayout库克隆,支持Android X的RecyclerView 详细使用说明,参考:https://github.com/alibaba/vlayout Main Fea

null 1 Dec 8, 2021
Quick Text is about send the message on WhatsApp without saving number. You can see the status of other and share and download those status also.

Quick Text is about send the message on WhatsApp without saving number. You can see the status of other and share and download those status also.

Dheeraj Gupta 11 May 25, 2022
News Stand app makes the ActionBar not boring!

No boring ActionBar http://flavienlaurent.com/blog/2013/11/20/making-your-action-bar-not-boring/ An explaination on how to implement the edition scree

Flavien Laurent 1.7k Oct 7, 2022