gpt4 book ai didi

codenameone - 如何在 Codenameone 中实现 float 操作按钮?

转载 作者:行者123 更新时间:2023-12-04 17:46:20 26 4
gpt4 key购买 nike

android 中的 float 操作按钮是不错的选择。我希望在我的 codenameone 应用程序中使用它。我通过使用 LayeredLayout 尝试过它,有两个布局。我无法完美地实现它。按钮随着滚动而不断移动。如何将按钮固定在屏幕的右下角而不影响背景层何时滚动。

这是我尝试的方法。

Form myForm = new Form();
myForm.setLayout(new LayeredLayout());
myForm.setTitle("Floating Action Button");

SpanLabel lbl = new SpanLabel("some long text");

Container conBottom = new Container();
conBottom.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
conBottom.addComponent(lbl);

FlowLayout flow = new FlowLayout(Component.RIGHT);
flow.setValign(Component.BOTTOM);
Container conUpper = new Container(flow);
conUpper.addComponent(new Button("+"));
conUpper.setScrollable(false);

myForm.addComponent(conBottom);
myForm.addComponent(conUpper);

myForm.show();

这是类似于我想要实现的链接。
https://github.com/Clans/FloatingActionButton
请帮忙!
谢谢!

最佳答案

表单的内容 Pane 正在执行滚动,您需要底部容器来处理滚动。
尝试这个:

    Form myForm = new Form();
myForm.setLayout(new LayeredLayout());
myForm.setTitle("Floating Action Button");

SpanLabel lbl = new SpanLabel("some long text ");

Container conBottom = new Container();
conBottom.setScrollableY(true);
conBottom.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
conBottom.addComponent(lbl);

FlowLayout flow = new FlowLayout(Component.RIGHT);
flow.setValign(Component.BOTTOM);
Container conUpper = new Container(flow);
conUpper.addComponent(new Button("+"));
conUpper.setScrollable(false);

myForm.addComponent(conBottom);
myForm.addComponent(conUpper);
myForm.setScrollable(false);
myForm.show();

关于codenameone - 如何在 Codenameone 中实现 float 操作按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33345381/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com