Mariano-

Well if the colors are publicly accessible you could access them
directly [find out the color resource identifiers by digging through
the source for the system theme/style xml files.. available in the Git
repo], something like: @android:color/resourceid .. This will allow
you to use the same colors a theme is using [providing those color
resources are public.. I've never tried this].

-Nick



On Apr 29, 2:46 am, Mariano Kamp <mariano.k...@gmail.com> wrote:
> Hey Pat.
>
> Thanks for your chipping in.
>
> No, I could also hardcode the colors and that is what it seems I will have
> to do. In my particular case it won't make much difference at the moment.
> For now I just need two values and they correspond to the light and dark.
> But for the future my needs will grow and it is also not so much fun to
> maintain a shadow theme administration on the side.
>
> I would have preferred to be a model citizen on the Android platform and use
> the themes. Hardcoding might be the quickest solution, but would fail if I
> want to use platform properties that are overwritten by vendor themes.
> To give you an example. On a stock Android device you'll see an orange
> background behind a selected list item, on an HTC sense device it would be
> green instead.
>
> Also as themes look so central to me, I was kind of hoping that I just
> missed the relevant documentation and that somebody else would point me to
> RTFM ;-)
>
> Cheers
> Mariano
>
> On Tue, Apr 27, 2010 at 9:38 AM, patbenatar <patbena...@gmail.com> wrote:
>
> Do you need to be doing this programatically? You could always take a
> screenshot of your phone [either using DDMS on a non-rooted device or
> the PicMe app on a rooted device] and then grab the colors using
> Photoshop or any image editing software. Another option, again not
> programmatic, would be to download the Android source [or you can
> browse it online in the Git repo] and find the declarations for those
> colors.
>
> -Nick
>
> On Apr 26, 3:23 am, Mariano Kamp <mariano.k...@gmail.com> wrote:
>
>
>
>
>
> > Hi,
>
> > I want to use colors from a Theme to apply it to HTML my app is rendering.
> I
> > am wondering if I can do that?
>
> > I am looking to use colors like they are specified in themes.xml:
>
> >         <item
> > name="colorForeground">@android:color/bright_foreground_dark</item>
> > ..
> >         <item name="colorBackground">@android:color/background_dark</item>
> > ..
> >         <item
> > name="textColorPrimary">@android:color/primary_text_dark</item>
> > ..
>
> > So it looks to me those are declared in the same way.
>
> > When trying to access those values this way:
>
> >         TypedValue tv = new TypedValue();
> >         getTheme().resolveAttribute(android.R.attr.colorBackground, tv,
> > true);
>
> >         System.out.println("tv.string=" + tv.string);
> >         System.out.println("tv.coerced=" + tv.coerceToString());
>
> >         int colorResourceId = getResources().getColor(tv.resourceId);
> >         System.out.println("colorResourceId=" + colorResourceId);
>
> >         tv = new TypedValue();
> >         getTheme().resolveAttribute(android.R.attr.textColorPrimary, tv,
> > true);
>
> >         System.out.println("tv.string=" + tv.string);
> >         System.out.println("tv.coerced=" + tv.coerceToString());
>
> >         colorResourceId = getResources().getColor(tv.resourceId);
> >         System.out.println("colorResourceId=" + colorResourceId);
>
> > I get this as a result:
>
> > I/System.out( 1578): tv.string=null
> > I/System.out( 1578): tv.coerced=#ffffffff
> > I/System.out( 1578): colorResourceId=-1
>
> > I/System.out( 1578): tv.string=res/color/primary_text_light.xml
> > I/System.out( 1578): tv.coerced=res/color/primary_text_light.xml
> > I/System.out( 1578): colorResourceId=-16777216
>
> > The results are different. The first one actually gives me the color
> > "#fffffff" which would work for me, the second one only gives me an xml.
>
> > Do I need to jump through a few more hoops here to resolve the actual
> color?
> > Does my original intention work at all? Maybe it won't work, because
> colors
> > could be arbitrary drawables?
>
> > I didn't find any relevant documentation, but if you know any, just point
> me
> > there please.
>
> > Btw. I also tried obtainStyledAttributes(), but this had basically the
> same
> > issues.
>
> > Cheers,
> > Mariano
>
> > --
> > 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<android-developers%2Bunsubs 
> > cr...@googlegroups.com>
> > For more options, visit this group athttp://
>
> groups.google.com/group/android-developers?hl=en
>
> --
> 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<android-developers%2Bunsubs 
> cr...@googlegroups.com>
> For more options, visit this group 
> athttp://groups.google.com/group/android-developers?hl=en
>
> --
> 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 
> athttp://groups.google.com/group/android-developers?hl=en

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