Datafield - detect default font size and color

Former Member
Former Member
Hi

Maybe this is a trivial question, but I have not been able to find the answer.

I am developing a datafield (not Simplefield) to be used mainly on Edge 1000 and 520.

My question is: how do I know what the default font size and color is (including the label with the name of the value)

I want my datafield to look like the built-in datafields, but I also want to be able to set the color different colors.

Any help is appriciated.

Michael
  • You can get the background color for DF's:

    bgColor=getBackgroundColor();

    And based on that, set a fgColor (if bgColor is black, make the fgColor white, for example). (On devices I use, it's either white on black or black on white, and not sure about the edge devices)

    As far as fonts, you can just figure out "what fits", and that could vary based on the DF you are running in. With a large DF (lets say 1 field), use a larger font than you would in a smaller (lets say 3 fields) sized DF .
  • The data field layout information used by the SimpleDataField is defined in {SDKROOT}/bin/devices.xml. The values should be very close to, or exactly the same as, what is used by the built-in data fields.

    Travis
  • Former Member
    Former Member over 9 years ago
    Thanks for the answers, I will look into that.

    However, on a ride yesterday, I discovered that my Edge1000 is set to go automatically in nightcolors, and my datafield that I was testing, was not.

    Isn't there a way to just let a datafield use systemcolors and behave like any other field?
  • If you are implementing SimpleDataField, or are using DataField.getBackgroundColor() (and setting the foreground color appropriately), it should do the right thing automatically.
  • As Travis said, with DataField.getBackgroundColor() on a regular DF, you should see it. When are you looking at that value?

    onLayout(), etc may not work for this, so you may have to do it in onUpdate().