Class “TextView”

Object > NativeObject > Widget > TextView

A widget to display a text. For images, use ImageView.

TextView on Android
Android
TextView on iOS
iOS
Constructor public
Singleton No
Namespace tabris
Direct subclasses None
JSX support Element: <TextView/>
Parent element: <Composite/> and any widget extending Composite
Child elements: None
Text content: Sets text property

Example

import {TextView, contentView} from 'tabris';

new TextView({
  left: 16, right: 16,
  text: 'Content'
}).appendTo(contentView);

See also:

Constructor

new TextView(properties?)

Parameter Type Optional Description
properties Properties<TextView> Yes Sets all key-value pairs in the properties object as widget properties.

Properties

alignment

The horizontal alignment of the text.

Type 'left' | 'right' | 'centerX'
Default 'left'
Settable Yes
Change events Yes

font

The font used for the text.

Type FontValue
Settable Yes
Change events Yes

lineSpacing

The amount of space between each line of text. The lineSpacing property is a factor with a default value of 1.0.

Type number
Default 1.0
Settable Yes
Change events Yes

markupEnabled

Allows for a subset of HTML tags in the text. Supported tags are: a, del, ins, b, i, strong, em, big, small, br. All tags must be closed (e.g. use <br/> instead of <br>). Nesting tags is not supported.

Type boolean
Settable Yes
Change events Yes

maxLines

Limit the number of lines to be displayed to the given maximum. null disables this limit.

Type number | null
Default null
Settable Yes
Change events Yes

selectable

Android

Whether the text can be selected or not.

Type boolean
Settable Yes
Change events Yes

text

The text to display.

Type string
Settable Yes
Change events Yes
JSX content type string

When using TextView as an JSX element the element content is mapped to this property. Therefore

<TextView>Hello World</TextView>

has the same effect as:

<TextView text='Hello World' />

textColor

The color of the text.

Type ColorValue
Settable Yes
Change events Yes

Events

Fires when the user clicks on a link in an html text. Requires to set markupEnabled to true and to provide a text containing an anchor (<a>) with an href attribute. Eg. textView.text = 'Website: <a href="http://example.com>example.com</a>'. The event object contains a property url which provides the anchors href url.

Parameter Type Description
url string The url referenced by the href attribute of the anchor.

Change Events

alignmentChanged

Fired when the alignment property has changed.

Parameter Type Description
value string The new value of alignment.

selectableChanged

Fired when the selectable property has changed.

Parameter Type Description
value boolean The new value of selectable.

markupEnabledChanged

Fired when the markupEnabled property has changed.

Parameter Type Description
value boolean The new value of markupEnabled.

textChanged

Fired when the text property has changed.

Parameter Type Description
value string The new value of text.

textColorChanged

Fired when the textColor property has changed.

Parameter Type Description
value ColorValue The new value of textColor.

maxLinesChanged

Fired when the maxLines property has changed.

Parameter Type Description
value number | null The new value of maxLines.

lineSpacingChanged

Fired when the lineSpacing property has changed.

Parameter Type Description
value number The new value of lineSpacing.

fontChanged

Fired when the font property has changed.

Parameter Type Description
value FontValue The new value of font.