Reputation: 3027
I've tried accordion and it doesn't expand and contract smoothly in both simulator and devices.Rather it expands and contract abruptly.
Please have a look at the video here.
And how come there are 2 scroll bars.(At the end of the video you'll see 2 scrollbars, the inner one will scroll and outermost will stay static) There appears an extra black line on the rightmost screen.
public final class LabourCategory extends Form {
public LabourCategory(Resources res) {
super(new BoxLayout(BoxLayout.Y_AXIS));
setTitle("Labour Category");
loadComponent(res);
revalidate();
}
public void loadComponent(Resources res) {
Container mainContainer = new Container(new BoxLayout(BoxLayout.Y_AXIS));
mainContainer.setUIID("small");
mainContainer.getAllStyles().setBgColor(0xcccccc);
mainContainer.getAllStyles().setBgTransparency(255);
mainContainer.getAllStyles().setMarginLeft(3);
add(mainContainer);
for (int i = 0; i < 10; i++) {
Accordion labourCategory = new Accordion();
labourCategory.addContent("Labour Category " + i,BoxLayout.encloseY(new Label("aaa"),new Label("bbb"), new Label("ccc")));
labourCategory.setUIID("small");
labourCategory.getAllStyles().setBgColor(0xffffff);
labourCategory.getAllStyles().setBgTransparency(255);
mainContainer.add(labourCategory);
}
}
}
Upvotes: 2
Views: 95
Reputation: 7483
To solve the jacky animation, change your form Layout to BorderLayout
and add the Accordion
to it directly or change mainContainer
also to BorderLayout
.
For the Scrollbar
, you will have to manually remove it as Accordion
is a subclass of Container
.
Lastly, you don't need multiple Accordion
for this purpose, just keep adding contents to one.
public final class LabourCategory extends Form {
public LabourCategory(Resources res) {
super(new BorderLayout());
setTitle("Labour Category");
loadComponent(res);
revalidate();
}
public void loadComponent(Resources res) {
Accordion labourCategory = new Accordion();
labourCategory.setUIID("small");
labourCategory.getAllStyles().setBgColor(0xffffff);
labourCategory.getAllStyles().setBgTransparency(255);
labourCategory.setScrollVisible(false); //removes scrollbar
for (int i = 0; i < 10; i++) {
labourCategory.addContent("Labour Category " + i, BoxLayout.encloseY(new Label("aaa"), new Label("bbb"), new Label("ccc")));
}
Container mainContainer = BorderLayout.center(labourCategory);
mainContainer.setUIID("small");
mainContainer.getAllStyles().setBgColor(0xcccccc);
mainContainer.getAllStyles().setBgTransparency(255);
mainContainer.getAllStyles().setMarginLeft(3);
add(CENTER, mainContainer);
}
}
Upvotes: 1