如何实现我的文本标签的相同行对齐以进行左对齐付款,并将其值对齐? 这是我的代码。是否有来自bixolon SPP-R300的SDK的功能,我该如何实现它。感谢。
JPOSprinting.mBixolonPrinter.printText("TOTAL AMOUNT PAID",alignmentLeft , textAttributeNormal, BixolonPrinter.TEXT_SIZE_HORIZONTAL1, false);
JPOSprinting.mBixolonPrinter.printText(AmtPd +"\n", alignmentRight,textAttributeNormal, BixolonPrinter.TEXT_SIZE_HORIZONTAL1, false);
答案 0 :(得分:1)
让我与您分享一些代码:
private final int LINE_CHARS = 42;
private void printTextColumns(String leftText, String rightText) {
if (leftText.length() + rightText.length() + 1 > LINE_CHARS) { // If two Strings cannot fit in same line
int alignment = BixolonPrinter.ALIGNMENT_LEFT;
int attribute = 0;
attribute |= BixolonPrinter.TEXT_ATTRIBUTE_FONT_C;
bixolonPrinter.printText(leftText, alignment, attribute, BixolonPrinter.TEXT_SIZE_HORIZONTAL1, false);
alignment = BixolonPrinter.ALIGNMENT_RIGHT;
attribute = 0;
attribute |= BixolonPrinter.TEXT_ATTRIBUTE_FONT_C;
bixolonPrinter.printText(rightText, alignment, attribute, BixolonPrinter.TEXT_SIZE_HORIZONTAL1, false);
} else {
int padding = LINE_CHARS - leftText.length() - rightText.length();
String paddingChar = " ";
for (int i = 0; i < padding; i++) {
paddingChar = paddingChar.concat(" ");
}
int alignment = BixolonPrinter.ALIGNMENT_LEFT;
int attribute = 0;
attribute |= BixolonPrinter.TEXT_ATTRIBUTE_FONT_C;
bixolonPrinter.printText(leftText + paddingChar + rightText, alignment, attribute, BixolonPrinter.TEXT_SIZE_HORIZONTAL1, false);
}
}
希望它符合你的需要!