Codenameone 如何将标签移动到中心位置
我想做的应用程序,当我按下标签按钮的结果(网站)将显示在中心。现在的结果是这样的,结果如下所示: 但我希望我的结果是这样的: 例如,当我按下home键时,会显示google网站,然后当我按下video选项卡时,它会变为youtube网站。 这是我的代码:Codenameone 如何将标签移动到中心位置,codenameone,Codenameone,我想做的应用程序,当我按下标签按钮的结果(网站)将显示在中心。现在的结果是这样的,结果如下所示: 但我希望我的结果是这样的: 例如,当我按下home键时,会显示google网站,然后当我按下video选项卡时,它会变为youtube网站。 这是我的代码: public void start() { if(current != null) { current.show(); return; } Toolbar.setGloba
public void start()
{
if(current != null)
{
current.show();
return;
}
Toolbar.setGlobalToolbar(true);
Form page = new Form("Apps", new BorderLayout());
Style s = UIManager.getInstance().getComponentStyle("TitleCommand");
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_BORDER_ALL, s);
page.getToolbar().addCommandToRightBar("", icon, (e) -> Log.p("Right"));
BrowserComponent browser = new BrowserComponent();
browser.setURL("https://google.com");
page.add(BorderLayout.CENTER, browser);
Tabs t = new Tabs();
Style st = UIManager.getInstance().getComponentStyle("Tab");
FontImage home = FontImage.createMaterial(FontImage.MATERIAL_HOME, st);
FontImage dash = FontImage.createMaterial(FontImage.MATERIAL_MUSIC_VIDEO, st);
FontImage cal = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, st);
t.addTab("Home", home, new Label("website 1"));
t.addTab("Video", dash, new Label("website 2"));
t.addTab("Search", cal, new Label("website 3"));
page.add(BorderLayout.SOUTH, t);
page.show();
}
你能帮我吗?谢谢您使用的是选项卡,没有添加任何内容<代码>选项卡替换屏幕的全部内容,这对于您试图完成的任务来说是不正确的。你一定把我的评论弄糊涂了,我提到了标签容器的底部模式 不要使用选项卡,只需使用切换按钮即可:
BrowserComponent browser = new BrowserComponent();
browser.setURL("https://google.com");
page.add(BorderLayout.CENTER, browser);
FontImage home = FontImage.createMaterial(FontImage.MATERIAL_HOME, st);
FontImage dash = FontImage.createMaterial(FontImage.MATERIAL_MUSIC_VIDEO, st);
FontImage cal = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, st);
ButtonGroup bg = new ButtonGroup();
RadioButton home = RadioButton.createToggle("Home", bg);
home.setMaterialIcon(FontImage.MATERIAL_HOME);
RadioButton dash = RadioButton.createToggle("Video", bg);
dash.setMaterialIcon(FontImage.MATERIAL_MUSIC_VIDEO);
RadioButton cal = RadioButton.createToggle("Search", bg);
cal.setMaterialIcon(FontImage.MATERIAL_SEARCH);
page.add(BorderLayout.SOUTH, GridLayout.encloseIn(3, home, dash, cal));
dash.addActionListener(e -> browser.setURL("https://youtube.com/"));
谢谢你的回复,如果我想改变按钮的颜色和大小。如何更改?您可以使用CSS或主题设计器自定义
ToggleButton
UIID,或使用按钮上的setUIID
更改其样式