Code example for ViewTreeObserver

Methods: removeOnGlobalLayoutListener

0
		gll = new OnGlobalLayoutListener() {
			@SuppressLint("NewApi") 
			@Override 
			public void onGlobalLayout() { 
				if (Build.VERSION.SDK_INT >= 16) {
					vto.removeOnGlobalLayoutListener(gll);
				}else { 
					vto.removeGlobalOnLayoutListener( gll );
				} 
				int distance = getScrollDistanceLeft();
				slideLeftInternal(distance);
			} 
		}; 
		if(vto != null && vto.isAlive()) {
			vto.addOnGlobalLayoutListener(gll);
		} 
	} 
 
	protected int getScrollDistanceLeft() { 
		View view = getChildAt(mSelectedIndex + menuItemStartPos);
		ViewGroup vg = (ViewGroup) view;