Codename one Layered Layout不填满屏幕

时间:2016-09-11 12:09:20

标签: layout codenameone layer

我用这个帖子实现了浮动按钮:How to achieve Floating Action Button in Codenameone? 但我有一个布局问题。内容不想填满屏幕。这是截图: enter image description here

这是我创建内容的方式:

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;
        }

如何让容器填满屏幕并制作' plus'右下方的按钮是否正确?

1 个答案:

答案 0 :(得分:2)

制作表格BorderLayout并将paneContainer放在中心