Example usage for android.widget RelativeLayout addView

List of usage examples for android.widget RelativeLayout addView

Introduction

In this page you can find the example usage for android.widget RelativeLayout addView.

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout);
    DatePicker datePicker = new DatePicker(this);
    layout.addView(datePicker);
}

From source file:edu.mit.collaborativewhiteboard.EditorActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_editor);

    // Create and attach the view that is responsible for painting.
    mCanvasView = new CanvasView(this);
    mCanvasView.requestFocus();/*from  w  w  w .  java  2s  .  c o m*/

    mDrawerLayout = (DrawerLayout) findViewById(R.id.editor_drawer_layout);

    RelativeLayout mMainLayout = (RelativeLayout) findViewById(R.id.editor_canvas);

    mMainLayout.addView(mCanvasView);

    mMenu = new EditorToolsMenu(this, R.id.editor_tools);

    mApplication = (MainApplication) getApplication();
    mApplication.getClient().initialize(this, mApplication.getUser().getName());
}

From source file:com.eggsoftware.flingsolver.gui.DrawSolutionPageAdapter.java

@Override
public Object instantiateItem(View collection, int position) {
    // Create the "Step N of T" TextView
    TextView stepTextView = new TextView(this.context);
    stepTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    stepTextView.setTextColor(Color.rgb(113, 113, 113));
    stepTextView.setGravity(Gravity.CENTER);
    stepTextView.setText(String.format(this.context.getResources().getString(R.string.step_of), position + 1,
            this.solution.size()));

    // Create the boar with the current step of the solution
    BoardCanvas board = new BoardCanvas(this.context);
    board.setBoardRepresentation(this.solution.get(position).getBoard());
    board.setArrow(this.solution.get(position).getRow(), this.solution.get(position).getCol(),
            this.solution.get(position).getDirection());

    // Add the components to the layout
    LinearLayout layout = new LinearLayout(this.context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(16, 20, 16, 16);// w ww.  j  a  v  a  2  s.  c o m

    RelativeLayout relativeLatout = new RelativeLayout(this.context);
    relativeLatout.setLayoutParams(
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));
    relativeLatout.addView(board);

    layout.addView(relativeLatout);
    layout.addView(stepTextView);
    ((ViewPager) collection).addView(layout, 0);
    return layout;
}

From source file:com.sim2dial.dialer.ui.PreferencesListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle b) {
    // Hack to correctly display preferences
    View view = inflater.inflate(R.layout.settings, null);

    ViewParent p = preferencesList.getParent();
    if (p != null) {
        ((ViewGroup) p).removeView(preferencesList);
    }//from   w  ww .  j  av a2 s  .com

    RelativeLayout layout = (RelativeLayout) view.findViewById(R.id.topLayout);
    layout.addView(preferencesList);

    postBindPreferences();
    return view;
}

From source file:com.keifermiller.inkbar.activities.IBActivity.java

@Override
public void setContentView(View view) {
    RelativeLayout iBContent = (RelativeLayout) View.inflate(this, R.layout.ib_activity_layout, null);
    iBContent.addView(view);
    super.setContentView(iBContent);
}

From source file:org.telegram.ui.ChangePhoneHelpActivity.java

@Override
public View createView(Context context) {
    actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setAllowOverlayTitle(true);

    TLRPC.User user = UserConfig.getCurrentUser();
    String value;/* www  .j  av a2  s  . c  o  m*/
    if (user != null && user.phone != null && user.phone.length() != 0) {
        value = PhoneFormat.getInstance().format("+" + user.phone);
    } else {
        value = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
    }

    actionBar.setTitle(value);
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            }
        }
    });

    fragmentView = new RelativeLayout(context);
    fragmentView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    RelativeLayout relativeLayout = (RelativeLayout) fragmentView;

    ScrollView scrollView = new ScrollView(context);
    relativeLayout.addView(scrollView);
    RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) scrollView.getLayoutParams();
    layoutParams3.width = LayoutHelper.MATCH_PARENT;
    layoutParams3.height = LayoutHelper.WRAP_CONTENT;
    layoutParams3.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
    scrollView.setLayoutParams(layoutParams3);

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setPadding(0, AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20));
    scrollView.addView(linearLayout);
    ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) linearLayout.getLayoutParams();
    layoutParams.width = ScrollView.LayoutParams.MATCH_PARENT;
    layoutParams.height = ScrollView.LayoutParams.WRAP_CONTENT;
    linearLayout.setLayoutParams(layoutParams);

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.phone_change);
    linearLayout.addView(imageView);
    LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
    imageView.setLayoutParams(layoutParams2);

    TextView textView = new TextView(context);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setGravity(Gravity.CENTER_HORIZONTAL);
    //textView.setTextColor(0xff212121);

    try {
        textView.setText(AndroidUtilities
                .replaceTags(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp)));
    } catch (Exception e) {
        FileLog.e("tmessages", e);
        textView.setText(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp));
    }
    linearLayout.addView(textView);
    layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
    layoutParams2.leftMargin = AndroidUtilities.dp(20);
    layoutParams2.rightMargin = AndroidUtilities.dp(20);
    layoutParams2.topMargin = AndroidUtilities.dp(56);
    textView.setLayoutParams(layoutParams2);

    textView = new TextView(context);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    textView.setGravity(Gravity.CENTER_HORIZONTAL);
    textView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent) /*0xff4d83b3*/);
    textView.setText(LocaleController.getString("PhoneNumberChange", R.string.PhoneNumberChange));
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16),
            AndroidUtilities.dp(12));
    textView.setBackground(context.getDrawable(R.drawable.list_selector));
    linearLayout.addView(textView);
    layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
    layoutParams2.width = LayoutHelper.WRAP_CONTENT;
    layoutParams2.height = LayoutHelper.WRAP_CONTENT;
    layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
    layoutParams2.leftMargin = AndroidUtilities.dp(20);
    layoutParams2.rightMargin = AndroidUtilities.dp(20);
    layoutParams2.topMargin = AndroidUtilities.dp(46);
    textView.setLayoutParams(layoutParams2);

    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (getParentActivity() == null) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setMessage(LocaleController.getString("PhoneNumberAlert", R.string.PhoneNumberAlert));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            presentFragment(new ChangePhoneActivity(), true);
                        }
                    });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
        }
    });

    return fragmentView;
}

From source file:com.markupartist.sthlmtraveling.utils.AdProxy.java

public ViewGroup getAdWithContainer(ViewGroup root, boolean attachToRoot) {
    int containerId = R.layout.ad_container_no_margins;

    RelativeLayout mAdContainer = (RelativeLayout) LayoutInflater.from(mContext).inflate(containerId, root,
            attachToRoot);/*from  ww  w . j av  a 2s .  c o  m*/

    if (mAdView != null) {
        mAdContainer.addView(mAdView);
    }
    return mAdContainer;
}

From source file:r2b.apps.view.base.BaseAbsListFragment.java

@Override
protected void initViews() {
    absListView = (AbsListView) getView().findViewById(android.R.id.list);

    emptyView = getEmptyView();//from   w w w .ja v a 2s . c om
    errorView = getErrorView();
    loadingView = getLoadingView();

    RelativeLayout.LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
    lp.addRule(RelativeLayout.CENTER_VERTICAL);
    RelativeLayout rl = new RelativeLayout(getActivity());
    rl.setLayoutParams(lp);

    if (emptyView != null) {
        rl.addView(emptyView);
    }
    if (errorView != null) {
        rl.addView(errorView);
    }
    if (loadingView != null) {
        rl.addView(loadingView);
    }

    ViewGroup parent = (ViewGroup) absListView.getParent();
    parent.addView(rl);
    absListView.setEmptyView(rl);

    showEmptyView();
}

From source file:com.microsoft.office.sfb.healthcare.SkypeCallFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mPreviewVideoTextureView = (TextureView) mRootView.findViewById(R.id.selfParticipantVideoView);
    RelativeLayout participantVideoLayout = (RelativeLayout) mRootView
            .findViewById(R.id.participantVideoLayoutId);
    mParticipantVideoSurfaceView = new MMVRSurfaceView(participantVideoLayout.getContext());
    participantVideoLayout.addView(this.mParticipantVideoSurfaceView);
    mListener.onFragmentInteraction(mRootView, getActivity().getString(R.string.callFragmentInflated));
    tryStartVideo();//  w ww  .  j a  v  a 2s  .co  m

}

From source file:com.adobe.plugins.FastCanvas.java

public void initView() {
    Log.i("CANVAS", "FastCanvas initView");
    mActivity.runOnUiThread(new Runnable() {
        @Override/*from w  ww . j a  va  2 s.c o m*/
        public void run() {
            final RelativeLayout top = new RelativeLayout(mActivity);
            top.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
                    RelativeLayout.LayoutParams.MATCH_PARENT));
            top.addView(mCanvasView);
            mActivity.setContentView(top);
        } // end run
    }); // end runnable
}