I am developing my new Android App and after I made the first layouts, I was wondering why everything is white (background) and not black like always before. So I figured out it is because of Theme.Holo.Light.DarkActionBar. I immediately changed it to Theme.Holo but nothing changed in the Emulator.
I googled the problem and they said that your minSDK has to be 11+, so I changed it to 11,12,13,14 but nothing changed again!
What can I do to see the old and nice black theme?
The values-v11 and values-v14 folders have styles.xml files in them that need to be updated in addition to the main one.
Use Theme.Holo. Since you elected not to post any source code, it is impossible to indicate where you are going wrong. However, if you run an app using a theme based upon Theme.Holo -- such as this sample app -- you get a dark background.
The easiest way to get Theme.Holo is to not specify a theme at all, as Theme.Holo is the default for apps with android:targetSdkVersion of 11 or higher and running on an API Level 11+ device.
The sample app I linked to takes a more elaborate approach, courtesy of Eclipse's code generators:
It has res/values/styles.xml defining AppTheme as inheriting from the old dark Theme:
It has res/values/styles.xml defining AppTheme as inheriting from Theme.Holo:
It uses AppTheme in its manifest (which for some reason is not displaying in this answer, so you will have to settle for clicking the link)
Hence, it will use Theme.Holo on API Level 11+ devices and Theme on older devices. Both supply a dark background.
Related
I am developing a really light-weight application which does not actually need a dedicated theme, so I removed android:theme attribute of the <application> tag in AndroidManifest.xml. That seems to work except that the application got dark theme. Is there a way to switch to the light one?
To clarify, I would like the application to have default theme that depends on the platform the application is running on, i.e. it is "Holo" for 4, "Material" for 5, and etc. And it is working now that way, but the theme variant is always dark, whilst I need the light one. I set the "minimum API" property to 14, but I am thinking about 11 as well.
I'm trying to change the theme of an app that I'm trying to develop using Android Studio. Apparently, there are at least two ways to do so: by editing the styles.xml file and by using the button above the preview (for me it's the middle button stating the name of the selected theme).
What I'm witnessing is this: When I try to change the theme by using the button, it will update the preview. When I edit the styles.xml file, neither the button caption nor the preview change. And when I run the application, neither the theme chosen using the button nor the theme specified in the styles.xml file are used.
So for example, I have chosen "Material Dark" using the button and specified Holo Light in styles.xml like so without the two interfering with each other at all:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>
And then, when I finally run the app in an emulator, I don't even know the theme (light gray action bar, black text color) that it displays the app in but it's not one that I have specified.
That being said, (almost) every other change I apply to the app in any way using Android Studio is displayed just fine both in the preview and in the emulator. An exception to that rule is the changing of the text color of the elements through the activity's XML file...
I'd appreciate any help, since I'm at my wit's end and also somewhat new to the whole thing.
Thanks! - koala
This is because ide sees no emulator. Emulator always run, but ide could hang up in state "Waiting for target device to come online".
Possible reason - Android API versions mismatch. Check if minSdkVersion and targetSdkVersion in Gradle Scripts - build.gradle (Module: app) correspond device API (also Synch push Synch Project with Gradle Files on a panel). Also low versions (e.g. API 15) result in ide-emulator link failure, inspite of application and device versions match.
I wanted to use Theme.Wallpaper in my app. This theme uses the phones current wallpaper as a background. The problem is it doesn't work on a 4.1 device. I also tried recreating the Theme.Wallpaper in my style resources but again it doesn't work for 4.1 devices.
- note that it may not work for lower APIs as well, I only confirmed it working on 2.2.1 and not working on 4.1.
I would like to know why it doesn't work and if there is any solution to that.
I have finally found the answer, it's a bit complex:
In a project built for a target above 14 (mine is 17) eclipse automatically creates a "values-v11" and a "values-v14" folders (applyed for phones or AVDs with api version 14 and above or 11 and above). In those folders are style.xml files that contain the "AppBaseTheme" style, This "AppBaseTheme" style replaces the one in the default "values" folder, which is the parent of (or: is extended by) the "AppTheme" style that is applyed by default to the application..
Now, the way I chose to apply the "Theme.Wallpaper" style to my app, was to have my "AppBaseTheme" inherit from it. Understanding this, it became obvious why my app did not have a "Theme.Wallpaper" like behavior on Systems with API 11 and above: I never made the alternative v11 and v14 "AppBaseTheme" extend the "Theme.Wallpaper" or the more suitable "Theme.Holo.Wallpaper" for v11, and "Theme.DeviceDefault.Wallpaper" for v14.
So, if you have troubles with applying styles, I hope you see this...
EDIT: if your reading this, and have troubles with editing the style.xml file in eclipse, try opening this file in any text editor (my favorite is notepad++) and just delete all the comments than reopen it on eclipse. In case you need comments just add them afterwords on your text editor.
When using the designer for Mono for Android in Visual Studio,
the controls have a nice clean design but as soon as you run the app on a device (emulator or real)the controls have a completely different style:
Is this because the designer uses a specific theme, if so which one,
or is there something else I have to do to get the same style on the device as in the designer?
You probably have the default theme set to Theme.Holo.Light in the designer. In the upper-right of the designer, you will see a button that allows you to select the theme. See the screenshot below.
If you need to change the theme to Holo light or just Holo, reference this post. You will need to make some themes resources and update your application manifest.
This normally happens when your Target Framework is set to Automatic - it will drop down the lowest theme it can use, you will want to change that to API 14/15 to pick up the "Halo" theme from within Android
I did a new theme on my app, that the parent is Theme.Sherlock.Light. On devices with API <3.0 the changes are working, but when the app is running on devices >=3.0 (in this case is 4.0.3) my new Style isn't working, still using the original Theme.Sherlock.Light.
How can I make an xml style that affects the style in a device with API <3.0 and the same on the devices >=3.0?
With ActionBarSherlock, you need to declare your styles twice: once with, and once without the android:-prefix.
See the examples here: http://actionbarsherlock.com/theming.html