在 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);