Cannot get textAppearance to inherit/cascade from theme

by Walt Armour » Fri, 19 Feb 2010 14:25:00 GMT

Sponsored Links
 I have a simple style like this:

        <style parent="android:Theme.Light.NoTitleBar" name="MyTheme">
            <item name="android:colorBackground">#FFFFFF</item>
            <item name="android:textAppearance">@style/PrimaryText</

And a simple style like this:

    <style parent="@android:style/TextAppearance" name="PrimaryText">
        <item name="android:textColor">#FF0000</item>
        <item name="android:textSize">14sp</item>

Now, I would expect (from reading everything that is documented) that
if I set the theme for my application like so:

    <application android:icon="@drawable/app_icon"
                                android:theme="@style/MyTheme" >

then anything in my app that has a textAppearance attribute (like a
TextView) would inherit the attributes from MyTheme (and thus the
attributes from PrimaryText).

But they don't.  I tried setting the theme on the specific activity
(in the manifest) and that did not work.  I set the style attribute on
the containing layout like this:


and that did nothing (which I believe is expected since this cascading
inheritance should only work when applied as a 'theme').

Am I missing something obvious here?  Right now I have to set the
textAppearance (or style) attribute on every single TextView to get
the style.  The pain is great.  Does anyone have a suggestion on a way
to get this to work?

While working this I also hit another oddity that may or may not be
related.  If I take the specific attributes (like textColor and
textSize) and put them in MyTheme then they do correctly cascade and
apply to all my text.  The problem is that they then cannot be
overridden by a style.  If I set textAppearance on a TextView it
appears to be ignored.  However, if I explicitly set textColor or
textSize then it will be honored and override the theme setting for
that TextView.

In general it feels like there is some missing wiring or a bit of
inconsistency in the application of themes and styling attributes.


Cannot get textAppearance to inherit/cascade from theme

by Prasanna Perera » Thu, 11 Mar 2010 02:06:24 GMT

 I am having this exact problem.  I am testing on the emulator.


Sponsored Links

Other Threads

1. Problem with new market and supporting screens?

Right now my app is built for 2.1.

However I can see a situation where I try to add the new XML tags to
tell the market what screens I support, but the tags are not in the
manifest schema.... which of course will prevent a build.

Does anyone else think this is going to be a problem?


2. which applications the user can install


I have some queries regarding app installation on a Android devices. I did
got though the link

1. Is there a way to control which applications can get installed on a
particular device? I mean apps signed with a particular key only should be

2. The ability to control that a .apk, can be installed only on a device,
which posses the corresponding public key is already there in Android 2.2.
Please let me know if this understanding of mine is correct and whether the
app installer automatically takes care of it?



3. [WTA] Program backup SMS dari Nokiyem 3210 classic ke Android ?

4. How can I use A-GPS

5. Can't download Gingerbread Source

6. How to Pre-load APK during Booting

7. Apakah galaxytab bisa video call ?