codenameonegui-builder

How to minimize gap between Tab icon and Tab text in Codename one?


I am writing an App with Codename One, but I cannot find out how to make the gap between a tab icon and a tab text smaller.

It looks like this:

currently

but it should look like this: (With the icons of the first picture though)

should

How can I minimize the gap between

Icon -> text

and

Icon -> content

?


Solution

  • That gap seems to be delivered from the icon itself and not from us. Assuming you used the material design icons make sure to set the padding to 0 e.g.

    FontImage.setDefaultPadding(0);
    

    Or:

    FontImage i = ...;
    i.setPadding(0);
    

    E.g:

    Form hi = new Form("Tabs", new BorderLayout());
    Tabs t = new Tabs();
    FontImage fim = FontImage.createMaterial(FontImage.MATERIAL_3D_ROTATION, "Tab", 4);
    fim.setPadding(0);
    t.addTab("AAA", fim, new Label("Tab 1"));
    t.addTab("BBB", fim, new Label("Tab 2"));
    hi.add(BorderLayout.CENTER, t);
    
    hi.show();
    

    enter image description here