Android Activity Set addView(Activity act, View v, Rect rect)

Here you can find the source of addView(Activity act, View v, Rect rect)

Description

add View

Declaration

public static RelativeLayout addView(Activity act, View v, Rect rect) 

Method Source Code

//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;
    }
}

Related

  1. setNavigationSelected(Activity activity, ArrayAdapter adapter, String selected)
  2. setNavigationList(Activity activity, SpinnerAdapter adapter, ActionBar.OnNavigationListener listener)
  3. setDisplayHomeAsUpEnabled(Activity activity, boolean b)
  4. setDisplayHomeAsUpEnabled(Activity activity, boolean b)
  5. onCreateSetTheme(Activity activity)
  6. enableHardwareAccelerate(Activity activity)