返回介绍

TextView

发布于 2020-10-20 06:58:14 字数 5819 浏览 844 评论 0 收藏 0

Extends Widget

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

Import this type with “const {TextView} = require('tabris');

AndroidiOS
TextView on AndroidTextView on iOS

Properties

alignment

Type: string, supported values: left, right, center, default: left

The horizontal alignment of the text.

lineSpacing

Type: number, default: 1.0

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

markupEnabled

Type: boolean

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 currently not supported.
This property can only be set on widget creation. Once set, it cannot be changed anymore.

maxLines

Type: *numbernull*, default: null

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

selectable

Android

Type: boolean

Whether the text can be selected or not. Currently only support on Android.

text

Type: string

The text to display.

textColor

Type: Color

The color of the text.

Events

alignmentChanged

Fired when the alignment property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: string The new value of alignment.

lineSpacingChanged

Fired when the lineSpacing property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: number The new value of lineSpacing.

maxLinesChanged

Fired when the maxLines property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: number|null The new value of maxLines.

selectableChanged

Fired when the selectable property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: boolean The new value of selectable.

textChanged

Fired when the text property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: string The new value of text.

textColorChanged

Fired when the textColor property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: Color The new value of textColor.

Example

const {TextView, ui} = require('tabris');

// Create text views with different alignments

new TextView({
  left: 10, top: 10, right: 10,
  text: 'Left',
  alignment: 'left'
}).appendTo(ui.contentView);

new TextView({
  left: 10, top: 'prev() 10', right: 10,
  text: 'Center',
  alignment: 'center'
}).appendTo(ui.contentView);

new TextView({
  left: 10, top: 'prev() 10', right: 10,
  text: 'Right',
  alignment: 'right'
}).appendTo(ui.contentView);

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文