Haha thanks for fixing that (and not baning me for losing my patience actually figuring the if statement was the culprit

)
The code I was refering is this one:
code for slpt centering:
Code: Select all
public static void setLayoutAlign(SlptViewComponent layout, int Align) {
layout.alignX = 2;
layout.alignY = 2;
if ((Align & 2) > 0) {
layout.alignX = 0;
} else if ((Align & 4) > 0) {
layout.alignX = 1;
} else if ((Align & 16) > 0) {
layout.alignY = 0;
} else if ((Align & 32) > 0) {
layout.alignY = 1;
}
}
As you can see if you leave the Align value to 0 or 1 it will consider it as the default value of 2 the same as the value for horizontal centering.
In the same code handling centering for the normal widget:
Code: Select all
int startY = this.y0;
int startX = this.x0;
int fontWidth = this.mFont.getFontWidth(result);
if ((this.align & 2) > 0) {
startX = this.x0;
} else if ((this.align & 4) > 0) {
startX = this.x1 - fontWidth;
} else if ((this.align & 8) > 0) {
startX = this.x0 + (((this.x1 - this.x0) - fontWidth) / 2);
}
int maxY = (this.y1 - this.y0) + 1;
Log.d("GtrDataWidget", "startX: " + Integer.toString(startX) + " startY: " + Integer.toString(startY) + "result:" + result);
this.mFont.drawText(canvas, result, this.align & 112, startX, startY, maxY, this.mGPaint);
Here the default value is the same as the left centered one, meaning that if align value is set to 0 or 1 it will be left centered.
Long story short you MUST set the value to 18 (or 19) for left aligned and top aligned, 34 (or 35) for left aligned and bottom aligned, and 66 (or 67) for left aligned and verticaly centered, or the behavior may change depending if in hi-fi or lo-fi.