For API 21+
<style name="AppTheme" parent="android:Theme.Holo.NoActionBar.TranslucentDecor">
...
</style>
For API 19+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowTranslucentStatus">true</item>
</style>
Your layout should have android:fitsSystemWindows="false"
(which is the default).
Now since you want to toggle the translucency you can do it programatically:
Window window = getWindow();
// Enable status bar translucency (requires API 19)
window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// Disable status bar translucency (requires API 19)
window.getAttributes().flags &= (~WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// Set a color (requires API 21)
window.setStatusBarColor(Color.RED);
I leave all the sdk version checking to you 🙂