예제 #1
0
        public override void LoadView()
        {
            var layout = new LinearLayout(Orientation.Vertical)
            {
                SubViews = new View[]
                {
                    _container = new LinearLayout(Orientation.Vertical)
                    {
                        SubViews = new[]
                        {
                            GetNestedHost(),
                        },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, AutoSize.WrapContent),
                    },
                    new NativeView()
                    {
                        View = new UILabel()
                        {
                            Text = "123",
                        }
                    },
                    new NativeView()
                    {
                        View = new UIButton()
                        {
                            Font = UIFont.SystemFontOfSize(24),
                            BackgroundColor = UIColor.Clear,
                                        AccessibilityIdentifier = "Hide/Show",
                        },
                        Init = v =>
                        {
                            v.As<UIButton>().BackgroundColor = UIColor.Black;
                            v.As<UIButton>().SetTitle("Hide/Show", UIControlState.Normal);
                            v.As<UIButton>().TouchUpInside += (sender, e) =>
                            {
                                _container.Gone = !_container.Gone;
                                View.LayoutSubviews();
                            };
                        }
                    },
                    new NativeView()
                    {
                        View = new UIView()	{ BackgroundColor = UIColor.Blue },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, AutoSize.FillParent),
                    },
                },
            };

            // We've now defined our layout, to actually use it we simply create a UILayoutHost control and pass it the layout
            this.View = new XibFree.UILayoutHost(layout);
            this.View.BackgroundColor = UIColor.Gray;
        }
예제 #2
0
파일: Demo1.cs 프로젝트: stefandevo/XibFree
        public override void LoadView()
        {
            // This is a simple vertical LinearLayout.   ViewGroups are not implemented as UIViews - they're simply scaffolding for
            // the layout of the contained NativeViews.  In this case we're setting up a horizontal linear layout.
            var layout = new LinearLayout(Orientation.Vertical)
            {
                SubViews = new View[]
                {
                    // A NativeView contains an iOS UIView
                    new NativeView()
                    {
                        // This is the UIView
                        View = new UIView(RectangleF.Empty)
                        {
                            // Set properties here
                            BackgroundColor = UIColor.Red,
                        },

                        // This controls how it's laid out by its parent view group (in this case the outer linear layout)
                        LayoutParameters = new LayoutParameters()
                        {
                            Width = AutoSize.FillParent,
                            Height = 50,
                        },
                    },

                    // A second view that will be stacked below the first
                    new NativeView()
                    {
                        View = new UIView(RectangleF.Empty)
                        {
                            BackgroundColor = UIColor.Blue,
                        },

                        LayoutParameters = new LayoutParameters()
                        {
                            Width = AutoSize.FillParent,
                            Height = 50,
                        },
                    },
                },
            };

            // We've now defined our layout, to actually use it we simply create a UILayoutHost control and pass it the layout
            this.View = new XibFree.UILayoutHost(layout);
            this.View.BackgroundColor=UIColor.Gray;
        }
예제 #3
0
		public override void LoadView()
		{
			// This is a simple vertical LinearLayout.   ViewGroups are not implemented as UIViews - they're simply scaffolding for 
			// the layout of the contained NativeViews
			var layout = new LinearLayout(Orientation.Vertical)
			{
				Padding = new UIEdgeInsets(10,10,10,10),
				Gravity = Gravity.CenterVertical,
				SubViews = new View[] 
				{
					// A NativeView contains an iOS UIView
					new NativeView()
					{
						// This is the UIView
						View = new UIView(CGRect.Empty)
						{
							// Set properties here
							BackgroundColor = UIColor.Red,
						},

						// This controls how it's laid out by its parent view group (in this case the outer linear layout)
						LayoutParameters = new LayoutParameters()
						{
							Width = AutoSize.FillParent,
							Height = 50,
						},
					},

					// Here we're nesting a horizontal linear layout inside the outer vertical linear layout
					new LinearLayout(Orientation.Horizontal)
					{
						// How to layout this linear layout within the outer one
						LayoutParameters = new LayoutParameters()
						{
							Height = AutoSize.WrapContent,
							Width = AutoSize.FillParent,
						},

						// Sub view collection
						SubViews = new View[]
						{
							new NativeView()
							{
								// This time we're showing a UILabel
								View = new UILabel(CGRect.Empty)
								{
									BackgroundColor = UIColor.Purple,
									Text="Hello World, this is a test to see if things wrap and measure correctly",
									Lines = 0,
									TextAlignment = UITextAlignment.Center,
									TextColor = UIColor.White
								},

								LayoutParameters = new LayoutParameters()
								{
									Width = AutoSize.FillParent,
									Height = AutoSize.WrapContent,		// Height calculated automatically based on text content!
								},
							},

							new NativeView()
							{
								// Here we're hosting a button
								View = new UIButton(UIButtonType.RoundedRect)
								{
									Tag = 123,
								},
								LayoutParameters = new LayoutParameters()
								{
									Width = AutoSize.WrapContent,				// Size of button determined by it's content
									Height = AutoSize.WrapContent,
									Gravity = Gravity.CenterVertical,
									Margins = new UIEdgeInsets(0, 10, 0, 0),	// Put a margin on the left to separate it from the text

								},
								Init = v =>
								{
									// Because we can't set a button's title with a property, we use the Init property
									// to execute some code.  Whatever action we assign to Init is simply executed immediately allowing
									// us to to keep this code here with the rest of the layout definition
									v.As<UIButton>().SetTitle("Hello", UIControlState.Normal);

									// We can also setup an event handler
									v.As<UIButton>().TouchUpInside += (sender,args) =>
									{
										new UIAlertView("Clicked", "", null, "OK").Show();
									};
								}
							},
						}
					},
					new NativeView()
					{
						View = new UIImageView(UIImage.FromBundle("logo320.png"))
						{
							ContentMode = UIViewContentMode.ScaleAspectFit,
							//BackgroundColor = UIColor.White
						},
						LayoutParameters = new LayoutParameters()
						{
							Width = AutoSize.FillParent,		// Overrall size determined by parent container width
							Height = AutoSize.WrapContent,		// Height will be calculated by calling Measurer below
							Margins = new UIEdgeInsets(10, 0, 0, 0)
						},
						Measurer = (v,s) =>
						{
							// By supplying a custom measurer, we can do clever things like calculate a height for this
							// image view that respects the aspect ratio of the image.  In this case the width is set
							// to match the parent, whereas the height is wrapped.  To calculate the height, XibFree will
							// call this function.
							var iv = (UIImageView)v;
							return new CGSize(s.Width, iv.Image.Size.Height * s.Width / iv.Image.Size.Width);
						},
					}
				},
			};

			// We've now defined our layout, to actually use it we simply create a UILayoutHost control and pass it the layout
			this.View = new XibFree.UILayoutHost(layout);
			this.View.BackgroundColor=UIColor.Gray;
		}
예제 #4
0
				public DemoTableViewCell() : base(UITableViewCellStyle.Default, "DemoTableViewCell")
				{
					Layout = new LinearLayout(Orientation.Horizontal)
					{
						Padding = new UIEdgeInsets(5,5,5,5),
						LayoutParameters = new LayoutParameters()
						{
							Width = AutoSize.FillParent,
							Height = AutoSize.WrapContent,
						},
						SubViews = new View[]
						{
							new NativeView()
							{
								View  = new UIImageView(CGRect.Empty)
								{
									Image = UIImage.FromBundle("tts512.png"),
								},
								LayoutParameters = new LayoutParameters()
								{
									Width = 40,
									Height = 40,
									Margins = new UIEdgeInsets(0,0,0,10),
								}
							},
							new LinearLayout(Orientation.Vertical)
							{
								LayoutParameters = new LayoutParameters()
								{
									Width = AutoSize.FillParent,
									Height = AutoSize.WrapContent,
								},
								SubViews = new View[]
								{
									new NativeView()
									{
										View = _labelTitle = new UILabel()
										{
											Text = "Title",
											BackgroundColor = UIColor.Clear,
											Font = UIFont.BoldSystemFontOfSize(18),
											HighlightedTextColor = UIColor.White,
										},
										LayoutParameters = new LayoutParameters()
										{
											Width = AutoSize.FillParent,
											Height = AutoSize.WrapContent,
										}
									},
									new NativeView()
									{
										View = _labelSubTitle = new UILabel()
										{
											Text = "SubTitle",
											BackgroundColor = UIColor.Clear,
											Font = UIFont.SystemFontOfSize(12),
											TextColor = UIColor.DarkGray,
											HighlightedTextColor = UIColor.White,
										},
										LayoutParameters = new LayoutParameters()
										{
											Width = AutoSize.FillParent,
											Height = AutoSize.WrapContent,
										}
									},
									new NativeView()
									{
										View = _labelLongText = new UILabel()
										{
											BackgroundColor = UIColor.Clear,
											Font = UIFont.SystemFontOfSize(12),
											TextColor = UIColor.DarkGray,
											HighlightedTextColor = UIColor.White,
											Lines = 0,
										},
										LayoutParameters = new LayoutParameters()
										{
											Width = AutoSize.FillParent,
											Height = AutoSize.WrapContent,
										}
									}
								}
							},
							new NativeView()
							{
								View = _labelPercent = new UILabel()
								{
									Text = "20%",
									BackgroundColor = UIColor.Clear,
									TextColor = UIColor.FromRGB(51,102,153),
									HighlightedTextColor = UIColor.White,
									Font = UIFont.BoldSystemFontOfSize(24),
									TextAlignment = UITextAlignment.Right,
								},
								LayoutParameters = new LayoutParameters()
								{
									Width = 50,
									Height = AutoSize.FillParent,
									Margins = new UIEdgeInsets(0, 10, 0, 0),
								}
							}
						}
					};


					this.ContentView.Add(new UILayoutHost(Layout, this.ContentView.Bounds));
					this.Accessory = UITableViewCellAccessory.DisclosureIndicator;
				}
예제 #5
0
        public override void LoadView()
        {
            // Create the layout
            var layout = new LinearLayout(Orientation.Vertical)
            {
                Padding = new UIEdgeInsets(10,10,10,10),
                Gravity = Gravity.CenterHorizontal,
                LayoutParameters = new LayoutParameters(AutoSize.FillParent, AutoSize.WrapContent),
                SubViews = new View[]
                {
                    new NativeView()
                    {
                        View = new UIImageView()
                        {
                            Image = UIImage.FromBundle("XibFree_512.png"),
                            ContentMode = UIViewContentMode.ScaleAspectFit,
                        },
                        LayoutParameters = new LayoutParameters()
                        {
                            Width = 120,
                            Height = 120,
                            MarginTop = 30,
                            MarginBottom = 20,
                        }
                    },
                    new Label("XibFree", UIFont.BoldSystemFontOfSize(24)),
                    new Label("Code-only layout for Xamarin.iOS", UIFont.SystemFontOfSize(12)),
                    new LinearLayout(Orientation.Horizontal)
                    {
                        Spacing = 10,
                        Gravity = Gravity.CenterHorizontal,
                        SubViews = new View[]
                        {
                            new Button("Download", () => Alert("Download")),
                            new Button("View Samples", () => Alert("Samples")),
                        },
                        LayoutParameters = new LayoutParameters()
                        {
                            Width = AutoSize.FillParent,
                            Height = AutoSize.WrapContent,
                            MarginTop = 50,
                        }
                    },
                    new NativeView()
                    {
                        View = new UIView()
                        {
                            BackgroundColor = UIColor.FromRGBA(0, 0, 0, 10),
                        },
                        LayoutParameters = new LayoutParameters()
                        {
                            Width = AutoSize.FillParent,
                            Height = 2,
                            MarginTop = 20,
                            MarginBottom = 20,
                        }
                    },
                    new Label("Step away from the mouse, build your UI in code!", UIFont.SystemFontOfSize(12)),
                }
            };

            // Create a UILayoutHost view to host the layout
            this.View = new UILayoutHostScrollable(layout)
            {
                // Yellowish background color
                BackgroundColor = UIColor.FromRGB(0xF1, 0xE8, 0xDC),
            };
        }
예제 #6
0
        public override void LoadView()
        {
            View panel;
            var layout = new LinearLayout(Orientation.Vertical)
            {
                SubViews = new View[]
                {
                    new NativeView()
                    {
                        View = new UIView()	{ BackgroundColor = UIColor.Blue },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, 50),
                    },
                    new LinearLayout(Orientation.Vertical)
                    {
                        Padding = new UIEdgeInsets(10,10,10,10),
                        Layer = new CAGradientLayer()
                        {
                            Colors = new MonoTouch.CoreGraphics.CGColor[]
                            {
                                new MonoTouch.CoreGraphics.CGColor(0.9f, 0.9f, 0.9f, 1f),
                                new MonoTouch.CoreGraphics.CGColor(0.7f, 0.7f, 0.7f, 1f)
                            },
                            Locations = new NSNumber[]
                            {
                                0.0f,
                                1.0f
                            },
                            CornerRadius = 5,
                        },
                        SubViews = new View[]
                        {
                            new NativeView()
                            {
                                View = new UILabel(RectangleF.Empty)
                                {
                                    Text="Hello World",
                                    Font = UIFont.SystemFontOfSize(24),
                                    BackgroundColor = UIColor.Clear,
                                }
                            },
                            panel = new NativeView()
                            {
                                View = new UILabel(RectangleF.Empty)
                                {
                                    Text="Goodbye",
                                    Font = UIFont.SystemFontOfSize(24),
                                    BackgroundColor = UIColor.Clear,
                                }
                            }
                        },
                        LayoutParameters = new LayoutParameters()
                        {
                            Width = AutoSize.FillParent,
                            Height = AutoSize.WrapContent,
                            Margins = new UIEdgeInsets(10,10,10,10),
                        },
                    },
                    new NativeView()
                    {
                        View = new UIView()	{ BackgroundColor = UIColor.Blue },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, 50),
                    },
                    new NativeView()
                    {
                        View = new UIButton(UIButtonType.RoundedRect),
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, AutoSize.WrapContent),
                        Init = v =>
                        {
                            v.As<UIButton>().SetTitle("Change Visibility", UIControlState.Normal);
                            v.As<UIButton>().TouchUpInside += (sender, e) =>
                            {
                                switch (panel.LayoutParameters.Visibility)
                                {
                                    case Visibility.Gone:
                                        panel.LayoutParameters.Visibility = Visibility.Visible;
                                        break;
                                    case Visibility.Visible:
                                        panel.LayoutParameters.Visibility = Visibility.Invisible;
                                        break;
                                    case Visibility.Invisible:
                                        panel.LayoutParameters.Visibility = Visibility.Gone;
                                        break;
                                }

                                this.View.SetNeedsLayout();
                            };
                        }
                    }
                },
            };

            // We've now defined our layout, to actually use it we simply create a UILayoutHost control and pass it the layout
            this.View = new XibFree.UILayoutHost(layout);
            this.View.BackgroundColor=UIColor.Gray;
        }
예제 #7
0
        public override void LoadView()
        {
            var layout = new LinearLayout(Orientation.Vertical)
            {
                SubViews = new View[]
                {
                    new NativeView()
                    {
                        View = new UIView()	{ BackgroundColor = UIColor.Blue },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, 50),
                    },
                    new LinearLayout(Orientation.Vertical)
                    {
                        Padding = new UIEdgeInsets(10,10,10,10),
                        Layer = new CAGradientLayer()
                        {
                            Colors = new MonoTouch.CoreGraphics.CGColor[]
                            {
                                new MonoTouch.CoreGraphics.CGColor(0.9f, 0.9f, 0.9f, 1f),
                                new MonoTouch.CoreGraphics.CGColor(0.7f, 0.7f, 0.7f, 1f)
                            },
                            Locations = new NSNumber[]
                            {
                                0.0f,
                                1.0f
                            },
                            CornerRadius = 5,
                        },
                        SubViews = new View[]
                        {
                            new NativeView()
                            {
                                View = new UILabel(RectangleF.Empty)
                                {
                                    Text="Hello World",
                                    Font = UIFont.SystemFontOfSize(24),
                                    BackgroundColor = UIColor.Clear,
                                }
                            },
                            new NativeView()
                            {
                                View = new UILabel(RectangleF.Empty)
                                {
                                    Text="Goodbye",
                                    Font = UIFont.SystemFontOfSize(24),
                                    BackgroundColor = UIColor.Clear,
                                }
                            }
                        },
                        LayoutParameters = new LayoutParameters()
                        {
                            Width = AutoSize.FillParent,
                            Height = AutoSize.WrapContent,
                            Margins = new UIEdgeInsets(10,10,10,10),
                        },
                    },
                    new NativeView()
                    {
                        View = new UIView()	{ BackgroundColor = UIColor.Blue },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, 50),
                    },
                },
            };

            // We've now defined our layout, to actually use it we simply create a UILayoutHost control and pass it the layout
            this.View = new XibFree.UILayoutHost(layout);
            this.View.BackgroundColor=UIColor.Gray;
        }
예제 #8
0
        public override void LoadView()
        {
            UILabel label;
            var layout = new LinearLayout(Orientation.Vertical)
            {
                SubViews = new View[]
                {
                    new NativeView()
                    {
                        View = new UIView()	{ BackgroundColor = UIColor.Blue },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, 50),
                    },
                    new LinearLayout(Orientation.Vertical)
                    {
                        Padding = new UIEdgeInsets(10,10,10,10),
                        Layer = new CAGradientLayer()
                        {
                            Colors = new CoreGraphics.CGColor[]
                            {
                                new CoreGraphics.CGColor(0.9f, 0.9f, 0.9f, 1f),
                                new CoreGraphics.CGColor(0.7f, 0.7f, 0.7f, 1f)
                            },
                            Locations = new NSNumber[]
                            {
                                0.0f,
                                1.0f
                            },
                            CornerRadius = 5,
                        },
                        SubViews = new View[]
                        {
                            new NativeView()
                            {
                                View = new UILabel(CGRect.Empty)
                                {
                                    Text="Hello World",
                                    Font = UIFont.SystemFontOfSize(24),
                                    BackgroundColor = UIColor.Clear,
                                }
                            },
                            new NativeView()
                            {
                                View = label = new UILabel(CGRect.Empty)
                                {
                                    Text="Goodbye",
                                    Font = UIFont.SystemFontOfSize(24),
                                    BackgroundColor = UIColor.Clear,
                                    Lines = 0,
                                },
                                LayoutParameters = new LayoutParameters(AutoSize.FillParent, AutoSize.WrapContent)
                            }
                        },
                        LayoutParameters = new LayoutParameters()
                        {
                            Width = AutoSize.FillParent,
                            Height = AutoSize.WrapContent,
                            Margins = new UIEdgeInsets(10,10,10,10),
                        },
                    },
                    new NativeView()
                    {
                        View = new UIView()	{ BackgroundColor = UIColor.Blue },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, 50),
                    },
                    new NativeView()
                    {
                                View = new UIButton(UIButtonType.RoundedRect) {
                                    AccessibilityIdentifier = "Change",
                                },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, AutoSize.WrapContent),
                        Init = v =>
                        {
                            v.As<UIButton>().SetTitle("Change Text", UIControlState.Normal);
                            v.As<UIButton>().TouchUpInside += (sender, e) =>
                            {
                                if (label.Text=="ShortString")
                                {
                                    label.Text = "This is a long string that should wrap and cause the layout to change";
                                    label.GetNativeView().LayoutParameters.Margins = new UIEdgeInsets(10,10,10,10);
                                }
                                else
                                {
                                    label.Text = "ShortString";
                                    label.GetNativeView().LayoutParameters.Margins = new UIEdgeInsets(20,20,20,20);
                                }
                                label.GetLayoutHost().SetNeedsLayout();
                                //or: this.View.SetNeedsLayout();
                            };
                        }
                    }
                },
            };

            // We've now defined our layout, to actually use it we simply create a UILayoutHost control and pass it the layout
            this.View = new XibFree.UILayoutHost(layout);
            this.View.BackgroundColor=UIColor.Gray;
        }
예제 #9
0
        public override void LoadView()
        {
            // This is a simple vertical LinearLayout.   ViewGroups are not implemented as UIViews - they're simply scaffolding for
            // the layout of the contained NativeViews
            var layout = new LinearLayout(Orientation.Vertical)
            {
                Padding = new UIEdgeInsets(50, 10, 10, 10),
                Gravity = Gravity.CenterVertical,
                SubViews = new View[]
                {
                    new NativeView()
                    {
                        // This is the UIView
                        View = new UILabel()
                        {
                            Text = "above",
                            Lines = 1,
                        },
                    },
                    new WrapLayout()
                    {
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, AutoSize.WrapContent),
                                Gravity = Gravity.Right,
                        SubViews = new View[]
                        {
                            // A NativeView contains an iOS UIView
                            new NativeView()
                            {
                                // This is the UIView
                                View = new UIView(CGRect.Empty)
                                {
                                    // Set properties here
                                    BackgroundColor = UIColor.Red,
                                },

                                // This controls how it's laid out by its parent view group (in this case the outer linear layout)
                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = 50,
                                    Height = 50,
                                },
                            },
                            new NativeView()
                            {
                                // This is the UIView
                                View = new UILabel()
                                {
                                    Text = "sada asd asd asd",
                                    Lines = 1,
                                },
                            },
                            new NativeView()
                            {
                                // This is the UIView
                                View = new UILabel()
                                {
                                    Text = "123 456 789 101112",
                                    Lines = 1,
                                },
                            },
                            new NativeView()
                            {
                                // This is the UIView
                                View = new UIView(CGRect.Empty)
                                {
                                    // Set properties here
                                    BackgroundColor = UIColor.Red,
                                },

                                // This controls how it's laid out by its parent view group (in this case the outer linear layout)
                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = 200,
                                    Height = 50,
                                },
                            },
                            new NativeView()
                            {
                                // This is the UIView
                                View = new UILabel()
                                {
                                    Text = "456 45 6",
                                    Lines = 1,
                                },
                                            LayoutParameters = new LayoutParameters() {
                                                Gravity = Gravity.Bottom,
                                            },
                            },
                        },
                    },
                    new NativeView()
                    {
                        // This is the UIView
                        View = new UILabel()
                        {
                            Text = "below",
                            Lines = 1,
                        },
                    },
                },
            };

            // We've now defined our layout, to actually use it we simply create a UILayoutHost control and pass it the layout
            this.View = new XibFree.UILayoutHost(layout);
            this.View.BackgroundColor = UIColor.Gray;
        }
예제 #10
0
        private NativeView GetNestedHost()
        {
            var layout = new LinearLayout(Orientation.Vertical)
            {
                SubViews = new[]
                {
                    new NativeView
                    {
                        View = new UILabel()
                        {
                            Text = "nested object",
                        }
                    },
                },
            };

            return new NativeView
            {
                View = new UILayoutHost(layout)
                {
                    BackgroundColor = UIColor.Gray,
                },
            };
        }
예제 #11
0
        public override void LoadView()
        {
            // This is a simple vertical LinearLayout.   ViewGroups are not implemented as UIViews - they're simply scaffolding for
            // the layout of the contained NativeViews
            var layout = new LinearLayout(Orientation.Vertical)
            {
                Padding = new UIEdgeInsets(10, 10, 10, 10),
                Gravity = Gravity.CenterVertical,
                SubViews = new View[]
                {
                    new NativeView()
                    {
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, 5),
                        View = new UIView()
                        {
                            BackgroundColor = UIColor.Yellow,
                        },
                    },
                    // Here we're nesting a horizontal linear layout inside the outer vertical linear layout
                    new GridLayout()
                    {
                        //for now you have to fill all RowDefinitions and ColumnDefinitions manually!!
                        RowDefinitions = new[]
                        {
                            new RowDefinition(),
                            new RowDefinition(),
                            new RowDefinition(),
                        },
                        ColumnDefinitions = new[]
                        {
                            new ColumnDefinition(),
                            new ColumnDefinition(),
                        },
                        ColSpacing = 5,
                        RowSpacing = 5,
                        Padding = new UIEdgeInsets(2, 2, 3, 4),
                        // How to layout this linear layout within the outer one
                        LayoutParameters = new LayoutParameters()
                        {
                            Height = AutoSize.WrapContent,
                            Width = AutoSize.FillParent,
                        },

                        // Sub view collection
                        SubViews = new View[]
                        {
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UILabel()
                                {
                                    BackgroundColor = UIColor.Purple,
                                    Text = "A:",
                                    Lines = 0,
                                    TextAlignment = UITextAlignment.Center,
                                    TextColor = UIColor.White
                                },
                                Row = 0,
                                Column = 0,
                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = AutoSize.WrapContent,
                                    Height = AutoSize.WrapContent,		// Height calculated automatically based on text content!
                                },
                            },
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UILabel()
                                {
                                    BackgroundColor = UIColor.Purple,
                                    Text = "sak hsldkh fals df",
                                    Lines = 0,
                                    TextAlignment = UITextAlignment.Center,
                                    TextColor = UIColor.White
                                },
                                Row = 0,
                                Column = 1,
                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = AutoSize.WrapContent,
                                    Height = AutoSize.WrapContent,		// Height calculated automatically based on text content!
                                },
                            },
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UILabel()
                                {
                                    BackgroundColor = UIColor.Purple,
                                    Text = "Asdfdsf s:",
                                    Lines = 0,
                                    TextAlignment = UITextAlignment.Center,
                                    TextColor = UIColor.White
                                },
                                Row = 1,
                                Column = 0,
                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = AutoSize.WrapContent,
                                    Height = AutoSize.WrapContent,		// Height calculated automatically based on text content!
                                },
                            },
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UILabel()
                                {
                                    BackgroundColor = UIColor.Purple,
                                    Text = "sak hsldkh fals df",
                                    Lines = 0,
                                    TextAlignment = UITextAlignment.Center,
                                    TextColor = UIColor.White
                                },
                                Row = 1,
                                Column = 1,
                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = AutoSize.WrapContent,
                                    Height = AutoSize.WrapContent,		// Height calculated automatically based on text content!
                                },
                            },
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UIView()
                                {
                                    BackgroundColor = UIColor.Green,
                                },
                                Row = 2,
                                Column = 1,
                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = AutoSize.FillParent,
                                    Height = 10,      // Height calculated automatically based on text content!
                                },
                            },
                        }
                    },
                },
            };

            // We've now defined our layout, to actually use it we simply create a UILayoutHost control and pass it the layout
            this.View = new XibFree.UILayoutHost(layout);
            this.View.BackgroundColor = UIColor.Gray;
        }
예제 #12
0
        public override void LoadView()
        {
            var layout = new LinearLayout(Orientation.Vertical)
            {
                SubViews = new View[]
                {
                    new NativeView()
                    {
                        View = new UIView()	{ BackgroundColor = UIColor.Blue },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, 50),
                    },
                    new NativeView()
                    {
                        View = new UILayoutHost()
                        {
                            BackgroundColor = UIColor.Yellow,
                            Layout = new LinearLayout(Orientation.Vertical)
                            {
                                Padding = new UIEdgeInsets(3,3,3,3),
                                SubViews = new View[]
                                {
                                    new NativeView()
                                    {
                                        View = new UILabel(RectangleF.Empty)
                                        {
                                            Text="Hello World",
                                            Font = UIFont.SystemFontOfSize(24),
                                            BackgroundColor = UIColor.Clear,
                                        }
                                    },
                                    new NativeView()
                                    {
                                        View = new UILabel(RectangleF.Empty)
                                        {
                                            Text="Goodbye",
                                            Font = UIFont.SystemFontOfSize(24),
                                            BackgroundColor = UIColor.Clear,
                                        }
                                    }
                                },
                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = AutoSize.FillParent,
                                    Height = AutoSize.WrapContent,
                                    Margins = new UIEdgeInsets(10,10,10,10),
                                },
                            },
                        },
                        Init = v =>
                        {
                            v.View.Layer.CornerRadius = 5;
                            v.View.Layer.MasksToBounds = true;
                        }
                    },
                    new NativeView()
                    {
                        View = new UIView()	{ BackgroundColor = UIColor.Blue },
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, 50),
                    },
                },
            };

            // We've now defined our layout, to actually use it we simply create a UILayoutHost control and pass it the layout
            this.View = new XibFree.UILayoutHost(layout);
            this.View.BackgroundColor=UIColor.Gray;
        }
예제 #13
0
        public override void LoadView()
        {
            // This is a simple vertical LinearLayout.   ViewGroups are not implemented as UIViews - they're simply scaffolding for
            // the layout of the contained NativeViews
            var layout = new LinearLayout(Orientation.Vertical)
            {
                Padding = new UIEdgeInsets(10, 10, 10, 10),
                Gravity = Gravity.CenterVertical,
                SubViews = new View[]
                {
                    new NativeView()
                    {
                        // This time we're showing a UILabel
                        View = new UILabel()
                        {
                            BackgroundColor = UIColor.Purple,
                            Text = "Hello World, this is a test to see if things wrap and measure correctly",
                            Lines = 0,
                            TextAlignment = UITextAlignment.Center,
                            TextColor = UIColor.White,
                        },

                        LayoutParameters = new LayoutParameters()
                        {
                            Width = AutoSize.WrapContent,
                            Height = AutoSize.WrapContent,
                        },
                    },

                    new LinearLayout(Orientation.Horizontal)
                    {
                        LayoutParameters = new LayoutParameters(AutoSize.FillParent, AutoSize.WrapContent),
                        Spacing = 5,
                        SubViews = new View[]
                        {
                            new NativeView()
                            {
                                LayoutParameters = new LayoutParameters(AutoSize.WrapContent, AutoSize.WrapContent)
                                {
                                },
                                View = new UILabel()
                                {
                                    Text = "asd as dasd asd as da fkasdhf aksdh fkljashd fklahsdfk lahsdlkf haslkdhf klashdfkasd",
                                    Lines = 0,
                                },
                            },
                            new NativeView()
                            {
                                LayoutParameters = new LayoutParameters(AutoSize.WrapContent, AutoSize.WrapContent)
                                {
                                    MinWidth = 50,
                                },
                                View = View = new UILabel()
                                {
                                    Text = "asd as"
                                },
                            },
                        },
                    },

                    new LinearLayout(Orientation.Horizontal)
                    {
                        LayoutParameters = new LayoutParameters(AutoSize.WrapContent, AutoSize.WrapContent),
                        Spacing = 5,
                        SubViews = new View[]
                        {
                            new NativeView()
                            {
                                LayoutParameters = new LayoutParameters(AutoSize.WrapContent, AutoSize.WrapContent)
                                {
                                },
                                View = new CustomButton("234 asdf asdf a sdfs"),
                            },
                            new NativeView()
                            {
                                LayoutParameters = new LayoutParameters(AutoSize.WrapContent, AutoSize.WrapContent)
                                {
                                },
                                View = new CustomButton("xcv"),
                            },
                            new NativeView()
                            {
                                LayoutParameters = new LayoutParameters(AutoSize.WrapContent, AutoSize.WrapContent)
                                {
                                },
                                View = new CustomButton("asd"),
                            },

                            new NativeView()
                            {
                                LayoutParameters = new LayoutParameters(30, 50),
                                View = new UIView() { BackgroundColor = UIColor.Green },
                            }
                        },
                    },

                    new LinearLayout(Orientation.Horizontal)
                    {
                        // How to layout this linear layout within the outer one
                        LayoutParameters = new LayoutParameters()
                        {
                            Height = AutoSize.WrapContent,
                            Width = AutoSize.FillParent,
                        },

                        // Sub view collection
                        SubViews = new View[]
                        {
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UILabel()
                                {
                                    BackgroundColor = UIColor.Purple,
                                    Text = "Hello World, this is a test to see if things wrap and measure correctly",
                                    Lines = 0,
                                    TextAlignment = UITextAlignment.Center,
                                    TextColor = UIColor.White
                                },

                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = AutoSize.WrapContent,
                                    Height = AutoSize.WrapContent,		// Height calculated automatically based on text content!
                                },
                            },
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UIView()
                                {
                                    BackgroundColor = UIColor.Yellow,
                                },

                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = 60,
                                    Height = AutoSize.FillParent,		// Height calculated automatically based on text content!
                                    MinWidth = 60,
                                },
                            },
                        }
                    },

                    // Here we're nesting a horizontal linear layout inside the outer vertical linear layout
                    new LinearLayout(Orientation.Horizontal)
                    {
                        // How to layout this linear layout within the outer one
                        LayoutParameters = new LayoutParameters()
                        {
                            Height = AutoSize.WrapContent,
                            Width = AutoSize.FillParent,
                        },

                        // Sub view collection
                        SubViews = new View[]
                        {
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UILabel()
                                {
                                    BackgroundColor = UIColor.Purple,
                                    Text = "Hello World, this is a test to see if things wrap and measure correctly",
                                    Lines = 0,
                                    TextAlignment = UITextAlignment.Center,
                                    TextColor = UIColor.White
                                },

                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = AutoSize.WrapContent,
                                    Height = AutoSize.WrapContent,		// Height calculated automatically based on text content!
                                    MinWidth = 50,
                                },
                            },
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UIView()
                                {
                                    BackgroundColor = UIColor.Purple,
                                },

                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = 20,
                                    MinWidth = 20,
                                    Height = AutoSize.FillParent,		// Height calculated automatically based on text content!
                                },
                            },
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UILabel()
                                {
                                    BackgroundColor = UIColor.Purple,
                                    Text = "Hello World, this is a test to see if things wrap and measure correctly",
                                    Lines = 0,
                                    TextAlignment = UITextAlignment.Center,
                                    TextColor = UIColor.White
                                },

                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = AutoSize.WrapContent,
                                    Height = AutoSize.WrapContent,		// Height calculated automatically based on text content!
                                    MinWidth = 50,
                                },
                            },
                        }
                    },

                    new LinearLayout(Orientation.Horizontal)
                    {
                        // How to layout this linear layout within the outer one
                        LayoutParameters = new LayoutParameters()
                        {
                            Height = AutoSize.WrapContent,
                            Width = AutoSize.FillParent,
                        },

                        // Sub view collection
                        SubViews = new View[]
                        {
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UILabel()
                                {
                                    BackgroundColor = UIColor.Purple,
                                    Text = "123 12 3123",
                                    Lines = 0,
                                    TextAlignment = UITextAlignment.Center,
                                    TextColor = UIColor.White
                                },

                                LayoutParameters = new LayoutParameters(100, AutoSize.WrapContent)
                                {
                                },
                            },
                            new NativeView()
                            {
                                // This time we're showing a UILabel
                                View = new UILabel()
                                {
                                    BackgroundColor = UIColor.Purple,
                                    Text = "Hello World, this is a test to see if things wrap and measure correctly",
                                    Lines = 0,
                                    TextAlignment = UITextAlignment.Center,
                                    TextColor = UIColor.White
                                },

                                LayoutParameters = new LayoutParameters()
                                {
                                    Width = AutoSize.WrapContent,
                                    Height = AutoSize.WrapContent,      // Height calculated automatically based on text content!
                                    MinWidth = 50,
                                },
                            },
                            new NativeView()
                            {
                                LayoutParameters = new LayoutParameters(AutoSize.FillParent, AutoSize.WrapContent)
                                {
                                    MarginLeft = 4,
                                },
                                View = new UILabel()
                                {
                                    Text = "",
                                },
                            }
                        }
                    },

                },
            };

            // We've now defined our layout, to actually use it we simply create a UILayoutHost control and pass it the layout
            this.View = new XibFree.UILayoutHost(layout);
            this.View.BackgroundColor = UIColor.Gray;
        }