Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Themes seemingly being ignored in ICS

I'm building an app that uses a few themes for its Activities. They all work fine and dandy on phones running pre-ICS versions of Android, but for some reason when I apply the themes on a Galaxy Nexus (running 4.1) and a Nexus S (running 4.0.4) the background is always black.

Here's one of the themes I'm using that's not working:

<style name="BlueStyle" parent="@android:style/Theme.Holo.NoActionBar">
    <item name="android:background">@color/Blue</item>
    <item name="android:textColor">@android:color/white</item>
    <item name="android:textSize">16dip</item>
</style>

The Blue color is defined in my res/values/colors.xml. The theme is in res/values-v11/styles.xml and is referenced in my manifest like so:

<activity
        android:name=".activity.SplashActivity"
        android:theme="@style/BlueStyle"
        android:configChanges="orientation|keyboardHidden|screenSize"/>

And like I said, a similar theme (under res/values, using @android:style/Theme.NoTitleBar as the parent) works fine for the same Activity in on pre-ICS versions of Android. Even if I go into the layout file and make the background of the layout @color/Blue, it will still be black if I have the theme assigned to the Activity. I have found, however, that if I set the theme to @android:style/Theme.NoTitleBar then the Activity will use the Blue color that I forced in the layout file.

I've also tried setting BlueStyle as the theme for the whole Application, but it makes no difference.

Anybody else experienced this issue before? This is my first time trying to support both pre-v11 and v11+ themes, so I might be making some really obvious error.

Edit: Also forgot to mention that I do see the blue color for a split second right when my Activity starts, but then the background turns black. Not sure if that info will help.

Edit #2: I also just tested on a Galaxy Tab 10.1 running 3.2 and it has the issue as well.

like image 439
BigFwoosh Avatar asked Nov 25 '22 20:11

BigFwoosh


1 Answers

From the looks of things, theming Activities is just plain broken in Honeycomb and above. I "solved" my issue by removing Activity-specific themes and adding the styles to my layout files instead.

If you run into this issue, make sure you remove the theme(s) from the Activities in your AndroidManifest.xml before you apply them to your layouts. Otherwise, the issue will persist.

like image 67
BigFwoosh Avatar answered Nov 29 '22 04:11

BigFwoosh