Code example for View

Methods: getRootView

0
	 *            any view which is attached to the content 
	 *  
	 * @return offset to top in pixel 
	 */ 
	public static int getContentOffsetFromTop(View view) {
		int offset = view.getRootView().findViewById(Window.ID_ANDROID_CONTENT).getTop();
		 
		if (offset == 0) {
			view.getWindowVisibleDisplayFrame(mStatusBarRect);
			offset = mStatusBarRect.top;
		} 
		 
		return offset;
	} 
	 
	/** 
	 * Get location of view relative to screen.<br> 
	 * <br> 
	 * <b>Note</b>: Call this when content is completely inflated. So {@code onCreate} of an 
	 * activity won't work.