【问题标题】:Codename one Layered Layout not fill the screen代号一分层布局不填满屏幕
【发布时间】:2016-09-11 12:09:19
【问题描述】:

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

这是我创建内容的方式:

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

如何让容器填满屏幕并正确设置右下角的“加号”按钮?

【问题讨论】:

标签: layout codenameone layer


【解决方案1】:

制作表单边框布局并将paneContainer放在中心

【讨论】:

  • 啊,你拯救了我的一天。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多