有很多可能性。您可以調整容納服務列表的容器邊距。你也可以讓你的自定義現場經理,以及更多。
選項1:調整量
VerticalFieldManager vfmServices = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH);
vfmServices.add(new RichTextField("• Computer & Laptop"));
vfmServices.add(new RichTextField("• Modem/Router/Switches"));
vfmServices.add(new RichTextField("• Printer/Scanner"));
vfmServices.add(new RichTextField("• Tablet"));
final int horizontalMargin = 30;
vfmServices.setMargin(0, horizontalMargin, 0, horizontalMargin);
add(vfmServices);
選項2:使用自定義字段經理
VerticalFieldManager vfmServiceLists = new VerticalFieldManager(VerticalFieldManager.USE_ALL_WIDTH);
vfmServiceLists.add(new RichTextField("• Computer & Laptop"));
vfmServiceLists.add(new RichTextField("• Modem/Router/Switches"));
vfmServiceLists.add(new RichTextField("• Printer/Scanner"));
vfmServiceLists.add(new RichTextField("• Tablet"));
Manager mListContainer = new Manager(Manager.USE_ALL_WIDTH) {
final int horizontalMargin = 30;
protected void sublayout(int width, int height) {
// this manager designed to contain only one list container.
if (getFieldCount() == 1) {
Field child = getField(0);
layoutChild(child, width - 2 * horizontalMargin, height);
// adjust manager height.
height = child.getHeight();
setPositionChild(child, horizontalMargin, 0);
}
setExtent(width, height);
}
};
mListContainer.add(vfmServiceLists);
add(mListContainer);
[後來添加]
由於alishaik786建議的評論,如果你使用的LabelField代替的RichTextField,您可以查看以下代碼,該代碼不使用任何保證金:
VerticalFieldManager vfmServiceLists = new VerticalFieldManager();
vfmServiceLists.add(new LabelField("• Computer & Laptop"));
vfmServiceLists.add(new LabelField("• Modem/Router/Switches"));
vfmServiceLists.add(new LabelField("• Printer/Scanner"));
vfmServiceLists.add(new LabelField("• Tablet"));
Manager mListContainer = new Manager(Manager.USE_ALL_WIDTH) {
protected void sublayout(int width, int height) {
// this manager designed to contain only one list container.
if (getFieldCount() == 1) {
Field child = getField(0);
layoutChild(child, width, height);
// adjust manager height.
height = child.getHeight();
setPositionChild(child, (width - child.getWidth())/2, 0);
}
setExtent(width, height);
}
};
mListContainer.add(vfmServiceLists);
add(mListContainer);
手段你要對每行作爲背景灰色的顏色?或者你需要直線最右邊和最左邊的位置? – 2012-01-11 04:27:13
嘗試使用標籤字段,而不是RichTextField – alishaik786 2012-01-11 04:55:04
由於RichTextField佔據了所有寬度,並且不會在其旁邊添加任何字段添加項。這時你必須使用sublayout()方法來提供一些寬度和高度;並給一些填充放置在屏幕中間。這就是爲什麼使用LabelField更好的原因 – alishaik786 2012-01-11 05:31:24