Transparent application theme with fade-in animation
My original suggestion was to use a Transparent full screen application theme (no action bar).
Combined with that, I always suggest an alpha-animation to fade across from the application theme to the activity theme. This prevents jarring to the user when the action bar appears.
OP's code would remain almost identical, except for changing the manifest theme, and adding the alpha animation in your onCreate()
method of some base activity class as in examples below:
manifest theme defined as:
android:theme="@android:style/Theme.Translucent.NoTitleBar"
base activity onCreate()
method:
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// set your custom theme here before setting layout
super.setTheme(android.R.style.Theme_Holo_Light_DarkActionBar);
setContentView(R.layout.activity_main);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
basic fade in:
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
basic fade out (not really needed, but for completeness):
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
Of course the animation durations here are way longer than you'd put in production - they are long so you can see them in your development stages.
Update #1:
It has been noted subsequently in comments by @EmanuelMoecklin, @androiddeveloper that this was considered. It is also included in answer by dentex. However, as the OP states, the weakness particularly on older devices is that the user gets no feedback when they try to launch the app. It appears the app takes too long to launch.
On KitKat, this is not the case, since the status bar & soft-keys change from transparent to black, while the rest of the screen is still transparent.
Another take on this approach would be to use a full-screen black background as the application theme. This is what was done by Bitspin for Timely, who were bought by Google apparently on the basis of the stunning UI in that app. It seems this method is therefore quite acceptable in many cases.
Update #2:
In order to speed up the perception of the launch, an alternative to the plain black theme is to use a full-screen image with the app's logo in the centre - "splash screen" style. Again fading across to the activity once launched.
This is not possible for the transparent theme, using a transparent full-screen image. Android ignores the transparency of the image (or overlays the transparent image onto a black background). This was pointed out by OP in the comments.
We can either have a transparent theme without an image, or an opaque theme with an image (an interesting topic for another question perhaps).
A note on using Manifest aliases
Another suggestion by @sergio91pt is to use aliases for different activities in the manifest.
While this can be a useful technique in some circumstances, in this case it has some drawbacks:
- Any HOME screen shortcut the user has created for the activity will stop working when the main launcher alias is changed i.e. each time the user changes themes.
- Some devices / launchers are quite slow to activate & deactivate the different aliases. In my experience this can take seconds (Galaxy Nexus 4.1 iirc), during which time you either have no visible launch icon, or you have 2 icons.
- Each possibly theme requires a different alias - this may prove cumbersome if there are many different themes.