How can I reposition the Floating Button in Codenameone?

无人久伴 提交于 2021-02-08 09:03:43

问题


The FloatingButton seems to be added only in Form.getContentPane() and cannot be added to a container Adding it to my form would make the button shield some components underneaths,

Any solution to this? I would like to have positioned inside the scrolling table in a BorderLayout.CENTER

not much options here:

fab.bindFabToContainer(current, Component.RIGHT, Component.CENTER);
    


回答1:


fab.bindFabToContainer(current, Component.RIGHT, Component.CENTER);

Doesn't add the fab to a container. It creates a new container and returns it so the right statement would be:

current = fab.bindFabToContainer(current, Component.RIGHT, Component.CENTER);
myForm.add(current);

Since the fab needs to float on top and we don't want to change your existing layout we create a new wrapper container with layered layout.

Notice that in the form/content page we can use the existing form layered layout (plus the content pane can't be replaced) so we detect that and use a special case with the layered pane.



来源:https://stackoverflow.com/questions/63763608/how-can-i-reposition-the-floating-button-in-codenameone

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!