2
我使用此線程實現了浮動按鈕:How to achieve Floating Action Button in Codenameone? 但我有佈局問題。內容不想填滿屏幕。下面的截圖: Codename one分層佈局不填滿屏幕
在這裏,我怎麼創建的內容:
final Container paneContainer = new Container(new LayeredLayout());
private Container getBottomContainer(Form parent) {
newsfeedContainer.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
newsfeedContainer.setScrollableY(true);
loadData();
newsfeedContainer.addPullToRefresh(new Runnable() {
public void run() {
loadData();
}
});
//newsfeedContainer.add(new Button("Button")).add(new Button("Button")).add(new Button("Button")).add(new Button("Button")).add(new Button("Button"));
return newsfeedContainer;
}
private Container getUpperContainer(Form par) {
FlowLayout flow = new FlowLayout(Component.RIGHT);
flow.setValign(Component.BOTTOM);
Container conUpper = new Container(flow);
Button plus = new Button();
FontImage.setMaterialIcon(plus, FontImage.MATERIAL_ADD, 5);
plus.addActionListener((ActionEvent evt) -> {
Form f = new PostComment().commentForm(parent);
f.getToolbar().setBackCommand(parent.getTitle(), BACK_POLICY, e -> parent.showBack());
f.show();
});
conUpper.addComponent(plus);
conUpper.setScrollableX(false);
conUpper.setScrollableY(false);
return conUpper;
}
public Container getContainer(Form parent) {
this.parent = parent;
paneContainer.setScrollableY(false);
paneContainer.addComponent(BorderLayout.center(getBottomContainer(parent)));
paneContainer.addComponent(BorderLayout.south(getUpperContainer(parent)));
return paneContainer;
}
如何使容器填滿屏幕,並在下方的「加號」按鈕右側正常嗎?
FYI https://www.codenameone.com/blog/floating-button.html –
嗨@ShaiAlmog如果C1具有開箱即用的浮動按鈕沒有意識到。感謝這個實現,將嘗試實現它。 – squallbayu
這是新的我們剛剛宣佈它 –