Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Context; import android.view.View; import android.view.ViewGroup; public class Main { private static void setupStatusBarView(Activity activity, ViewGroup contentLayout, int color) { View mStatusBarView = null; View statusBarView = new View(activity); ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity)); contentLayout.addView(statusBarView, lp); mStatusBarView = statusBarView; mStatusBarView.setBackgroundColor(color); } private static int getStatusBarHeight(Context context) { int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); return context.getResources().getDimensionPixelSize(resourceId); } }