When an app does not set the theme itself, it will call the system default theme.
Now the android default theme is black background and white text. I want to set the default theme due to my wish.
Who knows where can set the default theme in android project?
The android manifest.xml has the attribut android:theme="resource or theme". This attribut sets it to holo dark or light or your own declared theme. To use your own layout you msut declare and build your own layout in the res/values folder.
Here's the documentation about it: http://developer.android.com/guide/topics/manifest/application-element.html
In menifest.xml file you can set default theme like
<application
android:theme="#android:style/Theme.Black"
/>
Related
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
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
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.
Can I set a theme for the app I create?
I am talking about themes like in...
http://developer.android.com/design/style/themes.html
or should I use Styles and themes, and individually modify every child?
You indeed have to use Styles and Themes.
You can add a theme to whole of your application with just one line in the manifest:
<application android:theme="#style/CustomTheme">
Currently my android has black background and white foreground(text color), I want to change it to some other theme, is there any market available that I can download theme xml files that can be used in my app?
You don't have to download the light theme in order to use it. It comes with the system. You just need to indicate in your manifest that you'd like your activity to be shown with the light theme. Here is an example:
<activity android:name="NoteEditor"
android:theme="#android:style/Theme.Light"
>