1

My CodenameOne app has a BrowserComponent in the layout (it's a WebView).

It has also other components like TextFields.

I need that the text in the BrowserComponent has the same size as the text in the TextFields (default value).

I set the text size inside the BrowserComponent in HTML, using the CSS font-size property.

I tried with this instruction:

int size=textField.getStyle().getFont().getSize();

and then the HTML is created, where there is this string inside a suitable tag definition:

"style=\"font-size:"+String.valueOf(size)+"px;\"";

but the result is 0.

Is it possible to get that number to be correct from any method?

P5music
  • 3,197
  • 2
  • 32
  • 81

1 Answers1

0

First: You should use getUnselectedStyle() and not getStyle() before getFont().

The getSize() method is for system fonts as explained in the docs. You got the response of SIZE_MEDIUM which isn't what you want.

Try getHeight() or getPixelSize() after getFont().

P5music
  • 3,197
  • 2
  • 32
  • 81
Shai Almog
  • 51,749
  • 5
  • 35
  • 65