入门
开发指南
- 模块
- 控件基础知识
- 控件树
- 选择器 API
- 布局
- 手势和触摸事件
- W3C APIs 兼容
- Cordova 插件支持
- EcmaScript 6,TypeScript 和 JSX
- Windows 10 支持说明
- 构建 Tabris.js App
- Tabris.js App 补丁
API 参考文档
- app
- device
- fs
- localStorage
- ui
- ActionSheet(操作列表)
- AlertDialog(对话框)
- CanvasContext
- InactivityTimer(闲置定时器)
- NativeObject
- Popup(弹出窗)
- Timer(计时器)
- WidgetCollection
控件
- Action
- ActivityIndicator
- Button
- Canvas
- CheckBox
- CollectionView
- Composite
- Drawer
- ImageView
- NavigationBar
- NavigationView
- Page
- Picker
- ProgressBar
- RadioButton
- ScrollView
- SearchAction
- Slider
- StatusBar
- Switch
- Tab
- TabFolder
- TextInput
- TextView
- ToggleButton
- Video
- WebView
- Widget
自定义控件
Composite
Extends Widget
An empty widget that can contain other widgets.
Import this type with “const {Composite} = require('tabris');
”
Methods
append(…widgets)
Parameters:
- …widgets: Widget[]
Returns: this
Adds the given widgets to the composite.
append(widgets)
Parameters:
- widgets: Widget[]
Returns: this
Adds all widgets in the given array to the composite.
append(widgets)
Parameters:
- widgets: WidgetCollection
Returns: this
Adds all widgets in the given collection to the composite.
Properties
padding
Type: *BoxDimensions | number*, default: 0 |
Additional space to add inside the widget’s bounds. If set to a number, this padding will be applied on all four sides.
Events
addChild
Fired when a child is added to this widget.
Event Parameters
target: this The widget the event was fired on.
child: Widget The widget that is added as a child.
index: number Denotes the position in the children list at which the child widget is added.
paddingChanged
Fired when the padding property has changed.
Event Parameters
target: this The widget the event was fired on.
value: BoxDimensions|number The new value of padding.
removeChild
Fired when a child is removed from this widget.
Event Parameters
target: this The widget the event was fired on.
child: Widget The widget that is removed.
index: number The property
index
denotes the removed child widget’s position in the children list.`
Example
const {Composite, TextView, ui} = require('tabris');
// Create composites and append children to them
let composite1 = new Composite({
left: 0, top: 0, bottom: 0, right: '50%',
background: '#f3f3f3'
}).appendTo(ui.contentView);
new TextView({
left: 0, right: 0, top: '50%',
alignment: 'center',
text: 'Composite 1'
}).appendTo(composite1);
let composite2 = new Composite({
left: '50%', top: 0, bottom: 0, right: 0,
background: '#eaeaea'
}).appendTo(ui.contentView);
new TextView({
left: 0, right: 0, top: '50%',
alignment: 'center',
text: 'Composite 2'
}).appendTo(composite2);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论