AI2 Component  (Version nb184)
com.google.appinventor.components.runtime.Label Class Reference
Inheritance diagram for com.google.appinventor.components.runtime.Label:
com.google.appinventor.components.runtime.AndroidViewComponent com.google.appinventor.components.runtime.VisibleComponent com.google.appinventor.components.runtime.Component

Public Member Functions

 Label (ComponentContainer container)
 
View getView ()
 
int TextAlignment ()
 
void TextAlignment (int alignment)
 
int BackgroundColor ()
 
void BackgroundColor (int argb)
 
boolean FontBold ()
 
void FontBold (boolean bold)
 
boolean FontItalic ()
 
void FontItalic (boolean italic)
 
boolean HasMargins ()
 
void HasMargins (boolean hasMargins)
 
float FontSize ()
 
void FontSize (float size)
 
int FontTypeface ()
 
void FontTypeface (int typeface)
 
String Text ()
 
void Text (String text)
 
String HTMLContent ()
 
boolean HTMLFormat ()
 
void HTMLFormat (boolean fmt)
 
int TextColor ()
 
void TextColor (int argb)
 
- Public Member Functions inherited from com.google.appinventor.components.runtime.AndroidViewComponent
boolean Visible ()
 
void Visible (boolean visibility)
 
int Width ()
 
void Width (int width)
 
void WidthPercent (int pCent)
 
void setLastWidth (int width)
 
int getSetWidth ()
 
void setLastHeight (int height)
 
int getSetHeight ()
 
void CopyWidth (AndroidViewComponent sourceComponent)
 
int Height ()
 
void Height (int height)
 
void HeightPercent (int pCent)
 
void CopyHeight (AndroidViewComponent sourceComponent)
 
int Column ()
 
void Column (int column)
 
int Row ()
 
void Row (int row)
 
HandlesEventDispatching getDispatchDelegate ()
 

Additional Inherited Members

- Static Public Attributes inherited from com.google.appinventor.components.runtime.Component
static final String ASSET_DIRECTORY = "component"
 
static final int ALIGNMENT_NORMAL = 0
 
static final int ALIGNMENT_CENTER = 1
 
static final int ALIGNMENT_OPPOSITE = 2
 
static final int ACCELEROMETER_SENSITIVITY_WEAK = 1
 
static final int ACCELEROMETER_SENSITIVITY_MODERATE = 2
 
static final int ACCELEROMETER_SENSITIVITY_STRONG = 3
 
static final int BUTTON_SHAPE_DEFAULT = 0
 
static final int BUTTON_SHAPE_ROUNDED = 1
 
static final int BUTTON_SHAPE_RECT = 2
 
static final int BUTTON_SHAPE_OVAL = 3
 
static final int COLOR_NONE = 0x00FFFFFF
 
static final int COLOR_BLACK = 0xFF000000
 
static final int COLOR_BLUE = 0xFF0000FF
 
static final int COLOR_CYAN = 0xFF00FFFF
 
static final int COLOR_DKGRAY = 0xFF444444
 
static final int COLOR_GRAY = 0xFF888888
 
static final int COLOR_GREEN = 0xFF00FF00
 
static final int COLOR_LTGRAY = 0xFFCCCCCC
 
static final int COLOR_MAGENTA = 0xFFFF00FF
 
static final int COLOR_ORANGE = 0xFFFFC800
 
static final int COLOR_PINK = 0xFFFFAFAF
 
static final int COLOR_RED = 0xFFFF0000
 
static final int COLOR_WHITE = 0xFFFFFFFF
 
static final int COLOR_YELLOW = 0xFFFFFF00
 
static final int COLOR_DEFAULT = 0x00000000
 
static final String DEFAULT_VALUE_COLOR_NONE = "&H00FFFFFF"
 
static final String DEFAULT_VALUE_COLOR_BLACK = "&HFF000000"
 
static final String DEFAULT_VALUE_COLOR_BLUE = "&HFF0000FF"
 
static final String DEFAULT_VALUE_COLOR_CYAN = "&HFF00FFFF"
 
static final String DEFAULT_VALUE_COLOR_DKGRAY = "&HFF444444"
 
static final String DEFAULT_VALUE_COLOR_GRAY = "&HFF888888"
 
static final String DEFAULT_VALUE_COLOR_GREEN = "&HFF00FF00"
 
static final String DEFAULT_VALUE_COLOR_LTGRAY = "&HFFCCCCCC"
 
static final String DEFAULT_VALUE_COLOR_MAGENTA = "&HFFFF00FF"
 
static final String DEFAULT_VALUE_COLOR_ORANGE = "&HFFFFC800"
 
static final String DEFAULT_VALUE_COLOR_PINK = "&HFFFFAFAF"
 
static final String DEFAULT_VALUE_COLOR_RED = "&HFFFF0000"
 
static final String DEFAULT_VALUE_COLOR_WHITE = "&HFFFFFFFF"
 
static final String DEFAULT_VALUE_COLOR_YELLOW = "&HFFFFFF00"
 
static final String DEFAULT_VALUE_COLOR_DEFAULT = "&H00000000"
 
static final float FONT_DEFAULT_SIZE = 14
 
static final int LAYOUT_ORIENTATION_HORIZONTAL = ComponentConstants.LAYOUT_ORIENTATION_HORIZONTAL
 
static final int LAYOUT_ORIENTATION_VERTICAL = ComponentConstants.LAYOUT_ORIENTATION_VERTICAL
 
static final int SCALING_SCALE_PROPORTIONALLY = 0
 
static final int SCALING_SCALE_TO_FIT = 1
 
static final int TYPEFACE_DEFAULT = 0
 
static final int TYPEFACE_SANSSERIF = 1
 
static final int TYPEFACE_SERIF = 2
 
static final int TYPEFACE_MONOSPACE = 3
 
static final int LENGTH_PREFERRED = -1
 
static final int LENGTH_FILL_PARENT = -2
 
static final int LENGTH_UNKNOWN = -3
 
static final int LENGTH_PERCENT_TAG = -1000
 
static final int TOAST_LENGTH_SHORT = 0
 
static final int TOAST_LENGTH_LONG = 1
 
static final int DIRECTION_NORTH = 1
 
static final int DIRECTION_NORTHEAST = 2
 
static final int DIRECTION_EAST = 3
 
static final int DIRECTION_SOUTHEAST = 4
 
static final int DIRECTION_SOUTH = -1
 
static final int DIRECTION_SOUTHWEST = -2
 
static final int DIRECTION_WEST = -3
 
static final int DIRECTION_NORTHWEST = -4
 
static final int DIRECTION_NONE = 0
 
static final int DIRECTION_MIN = -4
 
static final int DIRECTION_MAX = 4
 
static float SLIDER_MIN_VALUE = 10
 
static float SLIDER_MAX_VALUE = 50
 
static float SLIDER_THUMB_VALUE = (SLIDER_MIN_VALUE + SLIDER_MAX_VALUE) / 2.0f
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_COUNTRY = ""
 
static final String DEFAULT_VALUE_TEXT_TO_SPEECH_LANGUAGE = ""
 
- Protected Member Functions inherited from com.google.appinventor.components.runtime.AndroidViewComponent
 AndroidViewComponent (ComponentContainer container)
 
- Protected Member Functions inherited from com.google.appinventor.components.runtime.VisibleComponent
 VisibleComponent ()
 
- Protected Attributes inherited from com.google.appinventor.components.runtime.AndroidViewComponent
final ComponentContainer container
 

Detailed Description

Labels are components used to show text.

Example of a label

A label displays text which is specified by the Text property. Other properties, all of which can be set in the Designer or Blocks Editor, control the appearance and placement of the text.

Definition at line 40 of file Label.java.

Constructor & Destructor Documentation

◆ Label()

com.google.appinventor.components.runtime.Label.Label ( ComponentContainer  container)

Creates a new Label component.

Parameters
containercontainer, component will be placed in

Definition at line 87 of file Label.java.

Member Function Documentation

◆ BackgroundColor() [1/2]

int com.google.appinventor.components.runtime.Label.BackgroundColor ( )

Returns the label's background color as an alpha-red-green-blue integer.

Returns
background RGB color with alpha

Definition at line 177 of file Label.java.

◆ BackgroundColor() [2/2]

void com.google.appinventor.components.runtime.Label.BackgroundColor ( int  argb)

Specifies the label's background color as an alpha-red-green-blue integer.

Parameters
argbbackground RGB color with alpha

Definition at line 190 of file Label.java.

◆ FontBold() [1/2]

boolean com.google.appinventor.components.runtime.Label.FontBold ( )

Returns true if the label's text should be bold. If bold has been requested, this property will return true, even if the font does not support bold.

Returns
true
indicates bold,
false
normal

Definition at line 209 of file Label.java.

◆ FontBold() [2/2]

void com.google.appinventor.components.runtime.Label.FontBold ( boolean  bold)

Specifies whether the label's text should be bold. Some fonts do not support bold.

Parameters
bold

Definition at line 223 of file Label.java.

◆ FontItalic() [1/2]

boolean com.google.appinventor.components.runtime.Label.FontItalic ( )

Returns true if the label's text should be italic. If italic has been requested, this property will return true, even if the font does not support italic.

Returns
true
indicates italic,
false
normal

Definition at line 238 of file Label.java.

◆ FontItalic() [2/2]

void com.google.appinventor.components.runtime.Label.FontItalic ( boolean  italic)

Specifies whether the label's text should be italic. Some fonts do not support italic.

Parameters
italic

Definition at line 252 of file Label.java.

◆ FontSize() [1/2]

float com.google.appinventor.components.runtime.Label.FontSize ( )

Returns the label's text's font size, measured in sp(scale-independent pixels).

Returns
font size in sp(scale-independent pixels).

Definition at line 302 of file Label.java.

◆ FontSize() [2/2]

void com.google.appinventor.components.runtime.Label.FontSize ( float  size)

Specifies the label's text's font size, measured in sp(scale-independent pixels).

Parameters
sizefont size in sp (scale-independent pixels)

Definition at line 314 of file Label.java.

◆ FontTypeface() [1/2]

int com.google.appinventor.components.runtime.Label.FontTypeface ( )

Returns the label's text's font face as default, serif, sans serif, or monospace.

Returns
one of Component#TYPEFACE_DEFAULT, Component#TYPEFACE_SERIF, Component#TYPEFACE_SANSSERIF or Component#TYPEFACE_MONOSPACE

Definition at line 330 of file Label.java.

◆ FontTypeface() [2/2]

void com.google.appinventor.components.runtime.Label.FontTypeface ( int  typeface)

Specifies the label's text's font face as default, serif, sans serif, or monospace.

Parameters
typefaceone of Component#TYPEFACE_DEFAULT, Component#TYPEFACE_SERIF, Component#TYPEFACE_SANSSERIF or Component#TYPEFACE_MONOSPACE

Definition at line 347 of file Label.java.

◆ getView()

View com.google.appinventor.components.runtime.Label.getView ( )

Returns the View that is displayed in the UI.

Reimplemented from com.google.appinventor.components.runtime.AndroidViewComponent.

Definition at line 130 of file Label.java.

◆ HasMargins() [1/2]

boolean com.google.appinventor.components.runtime.Label.HasMargins ( )

Returns true if the label should have margins.

Returns
true
indicates margins,
false
no margins

Definition at line 268 of file Label.java.

◆ HasMargins() [2/2]

void com.google.appinventor.components.runtime.Label.HasMargins ( boolean  hasMargins)

Specifies whether the label should have margins. This margin value is not well coordinated with the designer, where the margins are defined for the arrangement, not just for individual labels.

Parameters
hasMargins

Definition at line 284 of file Label.java.

◆ HTMLContent()

String com.google.appinventor.components.runtime.Label.HTMLContent ( )

Returns the content of the Label as HTML. This is only useful if the HTMLFormat property is true.

Returns
the HTML content of the label

Definition at line 387 of file Label.java.

◆ HTMLFormat() [1/2]

boolean com.google.appinventor.components.runtime.Label.HTMLFormat ( )

Returns the label's text's format

Returns
true
indicates that the label format is html text
false
lines that the label format is plain text

Definition at line 406 of file Label.java.

◆ HTMLFormat() [2/2]

void com.google.appinventor.components.runtime.Label.HTMLFormat ( boolean  fmt)

Specifies the label's text's format

Returns
true
indicates that the label format is html text
false
lines that the label format is plain text

Definition at line 419 of file Label.java.

◆ Text() [1/2]

String com.google.appinventor.components.runtime.Label.Text ( )

Returns the text displayed by the label.

Returns
label caption

Definition at line 359 of file Label.java.

◆ Text() [2/2]

void com.google.appinventor.components.runtime.Label.Text ( String  text)

Specifies the text displayed by the label.

Parameters
textnew caption for label

Definition at line 371 of file Label.java.

◆ TextAlignment() [1/2]

int com.google.appinventor.components.runtime.Label.TextAlignment ( )

Returns the alignment of the label's text: center, normal (e.g., left-justified if text is written left to right), or opposite (e.g., right-justified if text is written left to right).

Returns
one of Component#ALIGNMENT_NORMAL, Component#ALIGNMENT_CENTER or Component#ALIGNMENT_OPPOSITE

Definition at line 146 of file Label.java.

◆ TextAlignment() [2/2]

void com.google.appinventor.components.runtime.Label.TextAlignment ( int  alignment)

Specifies the alignment of the label's text: center, normal (e.g., left-justified if text is written left to right), or opposite (e.g., right-justified if text is written left to right).

Parameters
alignmentone of Component#ALIGNMENT_NORMAL, Component#ALIGNMENT_CENTER or Component#ALIGNMENT_OPPOSITE

Definition at line 163 of file Label.java.

◆ TextColor() [1/2]

int com.google.appinventor.components.runtime.Label.TextColor ( )

Returns the label's text color as an alpha-red-green-blue integer.

Returns
text RGB color with alpha

Definition at line 439 of file Label.java.

◆ TextColor() [2/2]

void com.google.appinventor.components.runtime.Label.TextColor ( int  argb)

Specifies the label's text color as an alpha-red-green-blue integer.

Parameters
argbtext RGB color with alpha

Definition at line 452 of file Label.java.


The documentation for this class was generated from the following file: