Note: You are on the beta version of our docs. This is a work in progress and may contain broken links and pages.
UI
Placeholder
<Placeholder>
allows you to add any native widget to your application. To do that, you need to put a Placeholder somewhere in the UI hierarchy and then create and configure the native widget that you want to appear there. Finally, pass your native widget to the event arguments of the creatingView event.
Creating a Simple Placeholder
xml
<Placeholder creatingView="creatingView" />
ts
import { Utils } from '@nativescript/core'
export function creatingView(args) {
let nativeView
if (global.isIOS) {
// Example with UITextView in iOS
nativeView = UITextView.new()
nativeView.text = 'Native View (iOS)'
} else if (global.isAndroid) {
// Example with TextView in Android
nativeView = new android.widget.TextView(
Utils.android.getApplicationContext()
)
nativeView.setText('Native View (Android)')
}
args.view = nativeView
}
Placeholder Reference(s)
Props
Name | Type | Description |
---|---|---|
N/A | N/A | None. |
...Inherited | Inherited | Additional inherited properties not shown. Refer to the API Reference |
Events
Name | Description |
---|---|
creatingView |
CreateViewEventData
Name | Type | Description |
---|---|---|
view | any | The native view that should be added to the visual tree. |
context | any | Optional: An optional context for creating the view. |