Skip to content

Instantly share code, notes, and snippets.

@jheerman
Created September 26, 2012 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jheerman/3788834 to your computer and use it in GitHub Desktop.
Save jheerman/3788834 to your computer and use it in GitHub Desktop.
M4A sample to center child view in relative layout
var viewContainer = new RelativeLayout(this);
var layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent);
AddContentView (viewContainer, layoutParams);
var btn = new Button(this) { Text = "Centered" };
var btnParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
btnParams.AddRule (LayoutRules.CenterInParent);
viewContainer.AddView (btn, btnParams);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment