-
StackOverflow 文档
-
nativescript 教程
-
使用本机小部件
-
在 ng2-TNS-Android 整体就绪示例中使用 surfaceView
app.component.ts:
import {Component,OnInit} from "@angular/core";
import placeholder = require("ui/placeholder");
let application= require("application");
@Component({
selector: "my-app",
templateUrl: "app.component.html",
})
export class AppComponent implements OnInit{
public creatingView(args: any) {
var nativeView = new android.view.SurfaceView(application.android.currentContext);
args.view = nativeView;
}
onLoaded(element){
let mSurface = element.android;
let holder = mSurface.getHolder();
}
public init: boolean = false;
ngOnInit() {
this.init = true;
}
}
app.component.html:
<StackLayout>
<Placeholder #surface *ngIf="init" (creatingView)="creatingView($event)" (loaded)="onLoaded(surface)"></Placeholder>
</StackLayout>