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

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?

change parent="android:Theme.Holo.Dark"
to parent="android:Theme.Holo"
The holo dark theme is called Holo

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" />

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>

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.

Related

Dialog Theme.DeviceDefault forced

I am making a dialog, where I want to show EditTexts and Radio buttons.
But the theme is not applying. According to Layout Inspector, the Views have the correct theme applied (shown "forced"), but there is "android:style/Theme.DeviceDefault()", which is also "forced" (it is shown above my style, if that matters).
The problem is, that the Views look differently on different APIs, which I guess is caused by that DeviceDefault. I have not set anywhere anything about DeviceDefault, but it applies to all my Dialogs.
Any idea how to dissmiss it? Thanks.
Every API level has its own default theme and since you use the default theme to your app, android adjusts the theme depending on the API level which will be different on each device. Just remember that just the element of which you add the style attribute to gets the specified style attributes. The child objects or child view does not get the style attribute. If you want child views to inherit styles, instead apply the style with the android:theme attribute.
The problem is probolby linked to where, and how, you apply your own theme.
You should apply your theme in the AndroidManifest.xml file. If you apply your theme in the application tag or the activity tag, you cover different parts of the application with your theme. What you have done is hard to say without any code present.
You should apply your theme to one of the following sections of the file.
To cover the whole application
<manifest ... >
<application android:theme="#style/Theme.AppCompat" ... >
</application>
</manifest>
To cover just one activity
<manifest ... >
<application ... >
<activity android:theme="#style/Theme.AppCompat.Light" ... >
</activity>
</application>
</manifest>
If a view supports only some of the attributes that you declared in the style that you created, it then only applies those attributes and ignores the ones it does not support.
If you want to change the default style and colors, you can override them in the styles.xml file. Search for the item name that represents the color value and change corresponding value in the res/values/colors.xml file.
I hope this information will solv your problem, but as I said, it this really hard so exactly say without the code present.
About Theme.DeviceDefaul in Android:
There are many Themes available for Android devices.
Theme: the default for the earliest versions of Android up to 2.3 Gingerbread(10)
Theme.Holo: from Android 3.0 Honeycomb (11)
Theme.Material: from Android 5.0 Lollipop (21)
Theme.DeviceDefault: from Android 4.0 Ice Cream Sandwich (14), a theme that can be customized by the device manufacturer. It represents the native look of the device.
Specifying different themes:
Android's resource overlay system allows to specify styles based on device API level, via Android Studio will setup for you.
For example different versions of a style in res/values-v11 and res/values-v21.
/res/values/styles.xml is applied to every device and serves as base:
<resources>
<style name="AppTheme" parent="android:Theme.Light"/>
</resources>
/res/values-v11/styles.xml is loaded on all devices that have API level 11 and above (including those that are 21 and above):
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light"/>
</resources>
/res/values-v21/styles.xml is loaded on all devices that have API level 21 and above:
<resources>
<style name="AppTheme" parent="android:Theme.Material.Light"/>
</resources>
AndroidManifest.xml is the place where the custom theme is put to use.
<application
android:theme="#style/AppTheme"
...

Application theme dose't change using Theme in Editor in Android Studio

Hi I'm new to Android and I just want to change my App theme using "Theme in Editor" in Android Studio the Theme is to change preview but when I run application I don't see any conversion and when I want to edit Apptheme attribute of style it doesn't recognize for example Holo theme.
Go to AndroidManifest.xml.In Application Tag press CTR+ click on android:theme="#style/AppTheme" It open the style.xml then change your theme as you want in style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Change android:theme="#style/AppTheme" to android:theme="#android:style/Theme.Holo" in your manifest file .

How to change app default theme to a different app theme?

I have an Android app that has a default theme of Holo.Light but I want to change it to Theme.Black.I tried to do this by changing the style tag in the manifest android:theme="#style/AppTheme" to Theme.Black but it cannot be found.Is there extra steps I have to take in changing the theme?
Actually you should define your styles in res/values/styles.xml. I guess now you've got the following configuration:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light"/>
<style name="AppTheme" parent="AppBaseTheme"/>
so if you want to use Theme.Black then change AppBaseTheme parent to android:Theme.Black or you could change app style directly in manifest file like this - android:theme="#android:style/Theme.Black". You must be lacking android namespace before style tag.
You can read more about styles and themes here.
To change your application to a different built-in theme, just add this line under application tag in your app's manifest.xml file.
Example:
<application
android:theme="#android:style/Theme.Holo"/>
<application
android:theme="#android:style/Theme.Holo.Light"/>
<application
android:theme="#android:style/Theme.Black"/>
<application
android:theme="#android:style/Theme.DeviceDefault"/>
If you set style to DeviceDefault it will require min SDK version 14, but if you won't add a style, it will set to the device default anyway.
<uses-sdk
android:minSdkVersion="14"/>
If you are trying to reference an android style, you need to put "android:" in there
android:theme="#android:style/Theme.Black"
If that doesn't solve it, you may need to edit your question with the full manifest file, so we can see more details
Or try to check your mainActivity.xml you make sure that this one
xmlns:app="http://schemas.android.com/apk/res-auto"hereis included

Using theme generated by Holo Style Generator

I managed to get this done a few days back but now I've forgotten what steps I took to make it work.
I've generated a custom widget theme from http://android-holo-colors.com
I've copied it to my res folder. I need to know what to change in the manifest and the styles.xml file to make it work with my app. I've tried a lot of different things but the theme either doesn't change or generates and xml error.
manifest.xml
<activity
android:name="com.yourapp.app"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:theme="#style/Theme.YourTheme"
...
</activity>
res/values/styles.xml
<style name="YourTheme" parent="android:Theme.Light">
...
</style>

Android app theme - difference when using theme from style xml file

Why is there a difference between theme defined in AndroidManifest.xml and theme taken from styles.xml?
1) AndroidManifest.xml:
<application ... android:theme="#android:style/Theme.Black">
2) AndroidManifest.xml
<application ... android:theme="#style/AppTheme">
styles.xml
<resources>
<style name="AppTheme" parent="#android:style/Theme.Black" />
</resources>
1st setting gives black theme and no action bar. 2nd has dark action bar and light menu.
EDIT : options 1) and 2) - notice Menu and ActionBar
EDIT 2:
Why doesn't the 2nd option actually use the AppTheme (Theme.Black) ? (tested on SGS3)
You probably have another styles.xml file, perhaps under a directory like "values-v11", that is defining the #style/AppTheme differently than #android:style/Theme.Black and taking precedence over the file you're viewing/modifying.
#android:style/Theme.Black implements the exact theme implemented by Android (or device manufacturer). However, #style/AppTheme allows you to perform custom modification in your theme which actually extends the original Theme.Black from android, and in order to perform custom modifications, you use style resources.
In simple words, its just like using Activity class or YourOwnActivity class which extends Activity with extra features inside.
Styles.xml enables you to create your own themes. In AndroidManifest, you set the theme you want for an app or activity. You may want to use a system theme or your own. You can also extend other themes as you're doing setting "parent" attribute. For further information, check this out:
http://developer.android.com/guide/topics/ui/themes.html
You should try to put:
<resources>
<style name="AppTheme" parent="#android:style/Theme.Black" />
</resources>
in a xml file called res/themes.xml

Categories

Resources