Preview 2.0 is now in Public Beta!
Read the Announcement
Note: You are on the beta version of our docs. This is a work in progress and may contain broken links and pages.

<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

NameTypeDescription
N/AN/ANone.
...InheritedInheritedAdditional inherited properties not shown. Refer to the API Reference

Events

NameDescription
creatingView

CreateViewEventData

NameTypeDescription
viewanyThe native view that should be added to the visual tree.
contextanyOptional: An optional context for creating the view.
Previous
ListView