Label
Last updated
Was this helpful?
Was this helpful?
// Initialize
var label = new Label();
label.AddToRoot();
label.Text = "This is a long string of text that will wrap to multiple lines when the label has a fixed width.";
label.Visual.Width = 200;
label.Visual.WidthUnits = Gum.DataTypes.DimensionUnitType.Absolute;
label.Visual.HeightUnits = Gum.DataTypes.DimensionUnitType.RelativeToChildren;// Initialize
var label = new Label();
label.AddToRoot();
label.Text = "Centered text";
label.Visual.Width = 300;
label.Visual.WidthUnits = Gum.DataTypes.DimensionUnitType.Absolute;
label.Visual.Height = 100;
label.Visual.HeightUnits = Gum.DataTypes.DimensionUnitType.Absolute;
var textRuntime = (Gum.GueDeriving.TextRuntime)label.TextComponent;
textRuntime.HorizontalAlignment = RenderingLibrary.Graphics.HorizontalAlignment.Center;
textRuntime.VerticalAlignment = RenderingLibrary.Graphics.VerticalAlignment.Center;// Initialize
var label = new Label();
label.AddToRoot();
// By default a Label sizes to its text content
label.Text = "Short text";
// Assign longer text and the label grows automatically
label.Text = "This is a much longer string of text";