Android Studio: app theme different in preview, running device and styles.xml - android

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.

Related

Change Android App Theme Permanently

I am making an app in Android Studio. I want to make the app full screen. I would change the theme using the button in the application, but if I change the phone or refresh the app, it would change back. Please help!
I think you're trying 'Design preview in Android studio'.
In 'Design' tab (where you're in right now), you can just see how it would look like in different phones and Android SDK versions.
If you want to change the App theme permanently,
Go to res/values/styles.xml and custom your own theme -ex) 'AppTheme'
In AndroidManifest.xml, you can set it via namespace 'theme' like this android:theme="#style/AppTheme"

Changing Android Theme causes Java exception at runtime

I've taken the basic Hello World app from the SDK examples and have been learning Android by modifying it. Currently I'm trying to change the Theme. I'm testing it on my Nexus 7 running the latest OS and I'm using Eclipse.
In my manifest I have
android:theme="#style/AppBaseTheme"
In values-v11/styles I have
style name="AppBaseTheme" parent="android:Theme.Black
I've tried using Holo and am aware I need to be V11 or higher to do that.
When I try running my app it starts on the tablet and I can see the black background as expected, but before it can draw any components Eclipse goes to debug mode in ActivityThread.performLaunchActivity and then into ZygoteInit$MethodAndArgsCaller.run() before my app dies.
If I use this it's fine:
style name="AppBaseTheme" parent="#style/Theme.AppCompat.Light"
I feel I'm missing something obvious or there's a fundamental part of Themes that I don't understand. I have tried removing the .android/ directory and restarting Eclipse, that fixed a few other issues.
I know the # symbol in this context denotes that it is an inbuilt style by android. Does that mean I have to add something to my app to link in other themes? If so what exactly?

Android Widget Look and Feel Different When Running

I am using Eclipse ADT to develop my first Android application.
In Eclipse you can change the theme using the menu shown in the Graphical Layout window. I decided to use the Black theme because I like the way the UI components look using that theme.
One of my UI widgets is a seek bar. Here is how it looks using the Black theme:
When I test (run) my application using the Nexus S virtual device the seek bar looks different:
Why do they look different? (I am guessing that Eclipse is just showing me a preview of what that theme would look like and not actually setting it anywhere and that when I run my app it inherits the theme from the target platform.) Is there a way I can force the look and feel of my app?
Thank you.
Because the Android UI has evolved and changed. The first image you posted is Android 2.2 (ish) and then the second image looks like Android >= 4.0.
Secondly, AFAIK, changing the theme from that menu is ONLY for checking out the apps UI within the GUI layout editor - it will not change the theme on launch within the emulator, or a real device. For that you need to specify the theme within your manifest.
You can change the version of Android being used in the preview too, using the Android icon on the far right of the GUI editor. You can also preview more than one at a time using the far left icon on the same toolbar.
What Rawkode said.
I'll add my two cents:
You can take a look at the HoloEverywhere project if you want to have a consistantly looking application across all Android versions.
The project is essentially a backport of the Holo theme for Android pre 4.0.
You can check it out here:
http://www.holoeverywhere.com/

use phone wallpaper as app background - Theme.Wallpaper like behaviour

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.

What theme does the Xamarin designer for Mono for Android use?

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

Categories

Resources