在 Nativescript 中实现 View.OnLayoutChangeListener
let playerLayoutChangeListener = new android.view.View.OnLayoutChangeListener( {
onLayoutChange : function ( v:View, left:number, top:number, right:number, bottom:number, oldLeft:number, oldTop:number, oldRight:number, oldBottom:number):any {
if (left != oldLeft || top != oldTop || right != oldRight || bottom != oldBottom) {
console.log("OnLayoutChangeListener");
__this.changeSurfaceLayout();
}
}
});
创建一个 surfaceView http://stackoverflow.com/documentation/proposed/changes/79536
添加监听器:
surfaceView.addOnLayoutChangeListener(playerLayoutChangeListener);
删除监听器:
surfaceView.removeOnLayoutChangeListener(playerLayoutChangeListener);