Skip to content

Instantly share code, notes, and snippets.

@codenameone
Created February 14, 2016 11:28
Show Gist options
  • Save codenameone/7289bbe5dad9e279eabb to your computer and use it in GitHub Desktop.
Save codenameone/7289bbe5dad9e279eabb to your computer and use it in GitHub Desktop.
Demonstrates the usage of ScaleImageButton & ScaleImageLabel in Codename One
TableLayout tl = new TableLayout(2, 2);
Form hi = new Form("ScaleImageButton/Label", tl);
Style s = UIManager.getInstance().getComponentStyle("Button");
Image icon = FontImage.createMaterial(FontImage.MATERIAL_WARNING, s);
ScaleImageLabel fillLabel = new ScaleImageLabel(icon);
fillLabel.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
ScaleImageButton fillButton = new ScaleImageButton(icon);
fillButton.setBackgroundType(Style.BACKGROUND_IMAGE_SCALED_FILL);
hi.add(tl.createConstraint().widthPercentage(20), new ScaleImageButton(icon)).
add(tl.createConstraint().widthPercentage(80), new ScaleImageLabel(icon)).
add(fillLabel).
add(fillButton);
hi.show();
@codenameone
Copy link
Author

Sample usage of ScaleImageButton & ScaleImageLabel.

From the Codename One project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment