Example usage for android.view SurfaceView getViewTreeObserver

List of usage examples for android.view SurfaceView getViewTreeObserver

Introduction

In this page you can find the example usage for android.view SurfaceView getViewTreeObserver.

Prototype

public ViewTreeObserver getViewTreeObserver() 

Source Link

Document

Returns the ViewTreeObserver for this view's hierarchy.

Usage

From source file:github.nisrulz.qreader.QREader.java

public void initAndStart(final SurfaceView surfaceView) {

    surfaceView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override/*from  w  ww. ja  v a 2s  . com*/
        public void onGlobalLayout() {
            init();
            start();
            removeOnGlobalLayoutListener(surfaceView, this);
        }
    });
}