<resources>
<bitmaps>
<bitmap id="launcherIcon" filename="images/icon_moon.png" />
</bitmaps>
<drawables>
<bitmap id="background" filename="images/kanji_gray.png" />
</drawables>
<layouts>
<layout id="MainLayout">layouts/MainLayout.xml</layout>
</layouts>
<strings>
<string id="AppName">Kyokushin Watchface</string>
</strings>
</resources>
<layout id="MainLayout">
<bitmap id="kanji_bg" filename="images/background.png" x="center" y="center" width="120" height="120" />
</layout>
Hi,
I am stuck with the design of my watchface and cannot find a solution. I am using the copilot as I am not a programmer. Here is what we can and can not do:
What works:
- Basic rendering (shapes, text, colors) ✓
- Resource compilation (Rez.Drawables.kanjiBg exists in generated code) ✓
- Building and deploying to simulator ✓
What fails:
WatchUi.loadResource(Rez.Drawables.*)→ "Invalid Resource Specified"Application.loadResource(Rez.Drawables.*)→ "Invalid Resource Specified"new WatchUi.Bitmap({:rezId => Rez.Drawables.*})→ "Invalid Resource Specified"- Layout-based loading → Empty drawable array
Device/SDK:
- Fenix 5S
- Connect IQ 3.1.0 (minSdkVersion in manifest)
- SDK 8.4.0
Our last watchface.mc looks like this:
using Toybox.Application as App;
using Toybox.WatchUi as WatchUi;
using Toybox.Graphics as Gfx;
using Toybox.Time;
class WatchFaceApp extends App.AppBase {
function initialize() { App.AppBase.initialize(); }
function getInitialView() { return [ new WatchFaceView() ]; }
}
class WatchFaceView extends WatchUi.WatchFace {
hidden var bgBitmap = null;
function initialize() {
WatchFace.initialize();
// Try to load bitmap once at initialization
try {
bgBitmap = App.loadResource(Rez.Drawables.kanjiBg);
} catch (e) {
bgBitmap = null;
}
}
function onUpdate(dc) {
dc.setColor(Gfx.COLOR_BLACK, Gfx.COLOR_BLACK);
dc.clear();
if (bgBitmap != null) {
dc.drawBitmap(0, 0, bgBitmap);
} else {
// Cyan = bitmap not loaded
dc.setColor(Gfx.COLOR_DK_GRAY, Gfx.COLOR_DK_GRAY);
dc.fillRectangle(20, 20, 178, 178);
dc.setColor(Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT);
dc.drawText(109, 109, Gfx.FONT_SMALL, "No Bitmap", Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER);
}
}
}