Datafields: Best practices for using layouts? Should I use layouts at all?

Former Member
Former Member
I'm new to Connect IQ and doing my first Datafields. Here is what I want to have:


My first try was to do all layouting (positioning/size of the arrows, font sizes etc) programatically which worked fine but wasn't that readable afterwards. The type of code with position-calculations you find very intuitive while writing it but don't understand it after a hour or two :)

So I tried to do things with different layouts. But I don't think Layouts are made for the different datafield sizes of the Edge series?!
  • There seems to be no way to automatically detect the size of the datafield and choose the right layout? For example I want to display the arrows on top or below the speed for big datafields and on the right for small datafields.
  • Also aligning the indicator arrows to the right seems to be impossible? You have to position it with a absolute X position, or am I missing something. I found no way to provide a percent value or (like in css) something like providing positioning relative to the right or bottom.
  • There seems to be no way to position shapes you defined in a drawable? For example I want to define the position of my arrows dynamically but drawable.setLocation() or drawable.locX=123; won't work.

So I ended up in a terrible mixture of defining some things in a layout and doing some things in the code. In my opinion this will increase complexity and coupling :(

So my main question is: Am I using the layouting via xml completely wrong? I've about 8 years of experience in web development (HTML, CSS, Javascript, Java) but Monkey C and the layouting concept seems to be quite different.
I was very frustrated when I started the simulator with the Edge 520 instead of the 1000 => Everything was overlapping and misaligned. This was much better wich my "code only" approach.
  • Personally, what you are seeing is one of the reasons I don't use layouts for much. Also, on devices with a 16k limit on df's, they seem to take more memory than they are worth.

    I use width and height (and maybe obscurity flags on round/semi-round) and then use my own x/y for displaying things, and even pick the font sizes that works. I set that in onLayout(), and things go from there...


    The current systems isn't doing much to separate view and logic. And I still have a feeling that I'm doing something wrong.

    Btw. the initial release of this power graph app is out. It just looks awful.
    https://apps.garmin.com/en-US/apps/0c8b753a-fb2c-416c-85dc-566a1f7fff53