How to set the holo dark theme in a Android app?

AndroidAndroid Theme

Android Problem Overview


How can I set the dark holo theme in my app? At this time I got this:

<style name="AppTheme" parent="android:Theme.Holo.Light" />

But when I change it to:

<style name="AppTheme" parent="android:Theme.Holo.Dark" />

I get an error error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Dark'.

How to solve the problem?

Android Solutions


Solution 1 - Android

change parent="android:Theme.Holo.Dark" to parent="android:Theme.Holo"

The holo dark theme is called Holo

Solution 2 - Android

By default android will set Holo to the Dark theme. There is no theme called Holo.Dark, there's only Holo.Light, that's why you are getting the resource not found error.

So just set it to:

<style name="AppTheme" parent="android:Theme.Holo" />

Solution 3 - Android

According the android.com, you only need to set it in the AndroidManifest.xml file:

http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme

Adding the theme attribute to your application element worked for me:

--AndroidManifest.xml--

...

<application ...

  android:theme="@android:style/Theme.Holo"/>
  ...

</application>

Solution 4 - Android

In your application android manifest file, under the application tag you can try several of these themes.

Replace

<application
    android:theme="@style/AppTheme" >

with different themes defined by the android system. They can be like:-

android:theme="@android:style/Theme.Black"
android:theme="@android:style/Theme.DeviceDefault"
android:theme="@android:style/Theme.DeviceDefault.Dialog"
android:theme="@android:style/Theme.Holo"
android:theme="@android:style/Theme.Translucent"

Each of these themes will have a different effect on your application like the DeviceDefault.Dialog will make your application look like a dialog box. You should try more of these. You can have a look from the android sdk or simply use auto complete in Eclipse IDE to explore the various available options.

A correct way to define your own theme would be to edit the styles.xml file present in the resources folder of your application.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiongurehbguiView Question on Stackoverflow
Solution 1 - AndroidLars WerkmanView Answer on Stackoverflow
Solution 2 - AndroidAnup CowkurView Answer on Stackoverflow
Solution 3 - AndroidPeter ShannonView Answer on Stackoverflow
Solution 4 - Androidnikoo28View Answer on Stackoverflow