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</
item>
        </style>

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>
    </style>

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:name=".MyApp"
                                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:

    <LinearLayout
      android:id="@+id/myLayout"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_margin="5sp"
      style="@style/MyTheme"
      android:background="@drawable/round_border">

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.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to