5

I have built android app with supporting android:minSdkVersion="7" android:targetSdkVersion="15". I use my customized theme inheriting Android default theme.

so now i want to change whole application theme to Holo theme.Can any one help me on this.

Praful Bhatnagar
  • 7,425
  • 2
  • 36
  • 44
Sanath
  • 493
  • 7
  • 22
  • 1
    You mean you want to change this programatically at run time? What about pre-honeycomb devices? Do you want them to have the Holo.Theme as well? Then you need something like Holoeverywhere. https://github.com/ChristopheVersieux/HoloEverywhere – Dirk Jäckel May 23 '12 at 08:57
  • Link to HoloEverywhere is now: https://github.com/Prototik/HoloEverywhere – Vincent Mimoun-Prat Sep 02 '13 at 12:46

3 Answers3

10

You can implement a "style selector" by using different style XMLs.

Just define a theme named "StyleSelector" or something like that in /res/**values**/styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="ThemeSelector" parent="@android:style/Theme.Black">
    ... Your theme definitions
    </style>
</resources>

Then create a /res/**values-v11**/styles.xml:

<resources>
    <style name="ThemeSelector" parent="@android:style/Theme.Holo">
    </style>
</resources>

Now just apply your theme with "@style/ThemeSelector" and let Android do the magic. On older Android versions, your theme definition will be loaded, on newer versions with Holo-Support, your theme will be derived from Holo.

Praful Bhatnagar
  • 7,425
  • 2
  • 36
  • 44
Bannane
  • 145
  • 2
  • 9
  • Although android documentation gives the same info, I get an error in eclipse even after specifying Theme.Black in values. I searched everywhere, but looks like there is no solution for this. Also I do not want to use any 3rd party libraries like HoloEveryWhere. – Manohar Dec 14 '12 at 15:06
  • Why not @android:style/Theme then? – Jeff May 12 '13 at 18:31
3

Try to use HoloEverywhere as parent theme.

galex
  • 3,279
  • 2
  • 34
  • 46
1

Just modify the application tag in the AndroidManifest.xml that it contains the theme:

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

For example like this:

<application android:icon="@drawable/ic_launcher"
             android:label="@string/app_name"
             android:theme="@style/Theme.Holo">

Or you can do it on a per Activity basis. Here is the relevant documentation: https://developer.android.com/guide/topics/ui/themes.html

Dirk Jäckel
  • 2,979
  • 3
  • 29
  • 47
  • I try this method but it gives error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.Holo'). – Sanath May 28 '12 at 08:36
  • Did this happen on a pre honeycomb device? If so, did you add the Holoeverywhere library? When using Holoeverywhere you have to use "@style/Theme.HoloEverywhereDark" – Dirk Jäckel May 28 '12 at 08:40
  • This is not run time error.this error gives from eclipse.so i can't build project. i will try HoloEverywhere theme.thanks for your help. – Sanath May 31 '12 at 08:16