2016-09-11 44 views
2

我使用此線程實現了浮動按鈕:How to achieve Floating Action Button in Codenameone? 但我有佈局問題。內容不想填滿屏幕。下面的截圖: enter image description hereCodename 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; 
     } 

如何使容器填滿屏幕,並在下方的「加號」按鈕右側正常嗎?

+0

FYI https://www.codenameone.com/blog/floating-button.html –

+0

嗨@ShaiAlmog如果C1具有開箱即用的浮動按鈕沒有意識到。感謝這個實現,將嘗試實現它。 – squallbayu

+0

這是新的我們剛剛宣佈它 –

回答

2

讓你的表格的BorderLayout並把paneContainer在中心

+0

啊,你救了我的一天。謝謝。 – squallbayu