Java tutorial
//package com.java2s; //License from project: Apache License import android.support.v4.view.ViewCompat; import android.view.ViewGroup; public class Main { /** * Hack since we don't have access to the private * android.support.design.widget.AppBarLayout.getTopInset() method */ public static int getTopInset(ViewGroup appBarLayout) { int inset = 0; int resourceId = appBarLayout.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (ViewCompat.getFitsSystemWindows(appBarLayout) && resourceId > 0) { inset = appBarLayout.getResources().getDimensionPixelSize(resourceId); } return inset; } }