I am placing text in a LabelField as multi-line. This is the method I am calling:
public void setFirstName(String fvalue,String lvalue,String date,String lastStatus)
{
_fnameLabel.setText(fvalue+" "+lvalue+"\n"+date+"\n"+lastStatus);
_fnameLabel.setFont((_fnameLabel.getFont().derive(Font.BOLD, 20, Ui.UNITS_px,
Font.ANTIALIAS_STANDARD, Font.COLORED_OUTLINE_EFFECT)));
_fnameLabel.setMargin(10, 0, 20, 0); //To leave some space from top and bottom
}
I want different font (size,style etc) for each line. Is it possible to have multi-format in one labelfield. Please help.
You can't do that with a
LabelField, only with aRichTextField. You have to build arrays of offsets, fonts, and font indices to use for the field. It's a bit tedious, but not particularly hard. The method you want to use iswhere:
offsetsis a sorted array of positions where formatting changes, including the start (0) and end (text.length()) of the text;attributesis an array of indexes into thefontsarray, one for each text region (offsets.length == attributes.length + 1);fontsis the array of different fonts you want to use.The
attributesarray can contain the same value more than once, sofonts.lengthcan be anything at all, as long as every element ofattributesis a valid index of a non-nullelement offonts.