dc.getWidth() and dc.getHeight() always report the full screen dc width and height also when you choose eg 4 fields from the menu Data Fields -> Layout -> choose something else than 1 field.
Expected behaviour: width and height should report the actual size of the datafield you're currently working with.
code to reproduce:
using Toybox.WatchUi as Ui;
using Toybox.Graphics as Gfx;
class layoutBugView extends Ui.DataField {
function initialize() {
DataField.initialize();
}
// Display the value you computed here. This will be called
// once a second when the data field is visible.
function onUpdate(dc) {
// Set the background color
var width = dc.getWidth();
var height = dc.getHeight();
System.println(width); // always returns same values in simulator. Ok on real device.
System.println(height);
dc.setColor(Gfx.COLOR_BLACK, Graphics.COLOR_TRANSPARENT);
dc.fillRectangle (0, 0, width, height);
// try with a 735xt 4 field target, you'll see these values won't be centered in all fields. (ok on real device)
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
dc.drawText(width / 2, 0, Gfx.FONT_SMALL, "Hello!", Gfx.TEXT_JUSTIFY_CENTER);
dc.drawText(width / 2, 30, Gfx.FONT_SMALL, "There!", Gfx.TEXT_JUSTIFY_CENTER);
}
}