Android examples for User Interface:View Margin
get Content Offset From Top View
//package com.java2s; import android.graphics.Rect; import android.view.View; import android.view.Window; public class Main { private static Rect mStatusBarRect = new Rect(); 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; }//from w w w . ja va2 s. c o m return offset; } }