Here you can find the source of addView(Activity act, View v, Rect rect)
public static RelativeLayout addView(Activity act, View v, Rect rect)
//package com.java2s; import android.app.Activity; import android.graphics.Rect; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.RelativeLayout; public class Main { public static RelativeLayout addView(Activity act, View v, Rect rect) { RelativeLayout rl = new RelativeLayout(act); ViewGroup fl = (ViewGroup) act.findViewById(android.R.id.content); fl = (ViewGroup) fl.getChildAt(0); fl.addView(rl, new FrameLayout.LayoutParams(-1, -1)); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( rect.width(), rect.height()); params.setMargins(rect.left, rect.top, 0, 0); rl.addView(v, params);/*from w w w .ja v a 2 s . c om*/ return rl; } }