这是我的自定义列表字段
public Custom_ListField(String title[], String date[], String category[]) {
super(0, ListField.MULTI_SELECT);
setRowHeight(80);
setCallback(this);
Background background = BackgroundFactory.createBitmapBackground(bg);
setBackground(background);
rows = new Vector();
for (int x = 0; x < title.length; x++) {
TableRowManager row = new TableRowManager();
titlelabel = new LabelField(title[x], DrawStyle.ELLIPSIS
| LabelField.USE_ALL_WIDTH | DrawStyle.LEFT);
titlelabel.setFont(Font.getDefault().derive(Font.BOLD, 25));
row.add(titlelabel);
datelabel = new LabelField(date[x], DrawStyle.ELLIPSIS
| LabelField.USE_ALL_WIDTH | DrawStyle.LEFT);
datelabel.setFont(Font.getDefault().derive(Font.BOLD, 20));
row.add(datelabel);
categorylabel = new LabelField(category[x], DrawStyle.ELLIPSIS
| LabelField.USE_ALL_WIDTH);
categorylabel.setFont(Font.getDefault().derive(Font.BOLD, 20));
row.add(categorylabel);
rows.addElement(row);
}
setSize(rows.size());
}
public void drawListRow(ListField listField, Graphics g, int index, int y, int width) {
list = (Custom_ListField) listField;
TableRowManager rowManager = (TableRowManager) list.rows.elementAt(index);
rowManager.drawRow(g, 0, y, width, list.getRowHeight());
}
private class TableRowManager extends Manager {
public TableRowManager() {
super(0);
}
public void drawRow(Graphics g, int x, int y, int width, int height) {
layout(width, height);
setPosition(x, y);
g.pushRegion(getExtent());
subpaint(g);
g.popContext();
}
protected void sublayout(int width, int height) {
Field field = getField(0);
layoutChild(field, getPreferredWidth() - 16, 25);
setPositionChild(field, 5, 5);
field = getField(1);
layoutChild(field, 100, 20);
setPositionChild(field, 5, 35);
field = getField(2);
layoutChild(field, 100, 20);
setPositionChild(field, 110, 35);
setExtent(getPreferredWidth(), getPreferredHeight());
}
这是结果。
如您所见,第一排和第二排看起来没有问题,但问题出现在第三排。文本的边距越来越大。为了看得清楚,我的背景图片确实有一条清晰的分隔线。
问题是什么?