Creating user interface layouts
All apps require some form of user interface for the user to input data or view the output of information.
How to do it...
Creating an interface for our apps is very easy. There are two ways to create user interfaces, with code or with XML:
- If we are using code to create a button on the screen, we would do something similar to this:
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); LinearLayout layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; Button button = new Button(this); button.Text = "Hello World!"; layout.AddView( button, ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); SetContentView(layout); }
Both XML and code can be used to create equivalent ...
Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.