private void bindViews() { // TIPS: create an observer for notify layout updated layoutapplication = (XKPLayout) findViewById(R.id.layoutapplication); ViewTreeObserver mainLayoutViewTreeObserver = layoutapplication.getViewTreeObserver(); if (mainLayoutViewTreeObserver.isAlive()) { mainLayoutViewTreeObserver.addOnGlobalLayoutListener( new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (!mLayoutStarted) { mLayoutStarted = true; onLayoutStarted(); } onLayoutUpdated(); } }); } }