Search…
Material Icons

Overview

Material Icons are the patterns of icons created by Google - Material Design. They are designed to be used in your Web/iOS/Android projects. Material Icons are available in a wide variety of densities and sizes, with more than 900 icons, as well as being Open Code.
To use the icons, import the MaterialIcons class:
import totalcross.ui.icon.MaterialIcons; Icon icon = new Icon(MaterialIcons.values());

Source Code

MaterialIconSample.java
1
import totalcross.sys.Settings;
2
import totalcross.ui.Container;
3
import totalcross.ui.MainWindow;
4
import totalcross.ui.icon.Icon;
5
import totalcross.ui.icon.MaterialIcons;
6
7
public class MaterialIconSample extends MainWindow {
8
9
public MaterialIconSample() {
10
setUIStyle(Settings.MATERIAL_UI);
11
Settings.uiAdjustmentsBasedOnFontHeight = true;
12
}
13
14
public void initUI() {
15
final int ICON_WIDTH = 64;
16
17
int cols = (int) (Math.min(Settings.screenWidth, Settings.screenHeight)
18
/ (ICON_WIDTH * Settings.screenDensity));
19
Container c = new Container() {
20
@Override
21
public void initUI() {
22
for (int i = 0, j = 0; i < MaterialIcons.values().length; i++, j++) {
23
Icon icon = new Icon(MaterialIcons.values()[i]);
24
icon.setFont(icon.getFont().adjustedBy(10));
25
add(icon, (j % cols) == 0 ? LEFT : AFTER, (j % cols) == 0 ? AFTER : SAME, PARENTSIZE + (100 / cols),
26
DP + ICON_WIDTH);
27
}
28
resizeHeight();
29
}
30
};
31
add(c, CENTER, TOP + 100, (int) (cols * ICON_WIDTH * Settings.screenDensity), WILL_RESIZE);
32
}
33
Copied!

References

Last modified 2yr ago