示例#1
0
        /// <summary>
        /// Initialize buttons that change flex layout properties
        /// </summary>
        private void InitButtons()
        {
            LinearLayout ButtonLayout = new LinearLayout();

            ButtonLayout.LinearOrientation = LinearLayout.Orientation.Horizontal;
            ButtonView.Layout = ButtonLayout;

            // Initialize Button1
            Button1 = new Button();
            Button1.BackgroundColor    = new Color(0.25f, 0.25f, 0.25f, 1.0f);
            Button1.HeightResizePolicy = ResizePolicyType.FillToParent;
            Button1.Text      = "Dir";
            Button1.TextColor = Color.White;
            Button1.Margin    = new Extents(10, 10, 10, 10);
            Button1.Weight    = 0.25f;

            // Initialize Button2
            Button2 = new Button();
            Button2.BackgroundColor    = new Color(0.25f, 0.25f, 0.25f, 1.0f);
            Button2.HeightResizePolicy = ResizePolicyType.FillToParent;
            Button2.Text      = "Just";
            Button2.TextColor = Color.White;
            Button2.Margin    = new Extents(10, 10, 10, 10);
            Button2.Weight    = 0.25f;

            // Initialize Button3
            Button3 = new Button();
            Button3.BackgroundColor    = new Color(0.25f, 0.25f, 0.25f, 1.0f);
            Button3.HeightResizePolicy = ResizePolicyType.FillToParent;
            Button3.Text      = "Align";
            Button3.TextColor = Color.White;
            Button3.Margin    = new Extents(10, 10, 10, 10);
            Button3.Weight    = 0.25f;

            // Initialize Button4
            Button4 = new Button();
            Button4.BackgroundColor    = new Color(0.25f, 0.25f, 0.25f, 1.0f);
            Button4.HeightResizePolicy = ResizePolicyType.FillToParent;
            Button4.Text      = "Wrap";
            Button4.TextColor = Color.White;
            Button4.Margin    = new Extents(10, 10, 10, 10);
            Button4.Weight    = 0.25f;

            // Add Buttons to parent view
            ButtonView.Add(Button1);
            ButtonView.Add(Button2);
            ButtonView.Add(Button3);
            ButtonView.Add(Button4);

            // Register button click events
            Button1.ClickEvent += Button1Clicked;
            Button2.ClickEvent += Button2Clicked;
            Button3.ClickEvent += Button3Clicked;
            Button4.ClickEvent += Button4Clicked;
        }
        /// <summary>
        /// Initialize buttons that change flex layout properties
        /// </summary>
        private void InitButtons()
        {
            LinearLayout ButtonLayout = new LinearLayout();

            ButtonLayout.LinearOrientation = LinearLayout.Orientation.Horizontal;
            ButtonView.Layout = ButtonLayout;

            // Initialize Button1
            Button1 = new Button()
            {
                BackgroundColor     = new Color(0.25f, 0.25f, 0.25f, 1.0f),
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.WrapContent,
                Text      = "Dir",
                TextColor = Color.White,
                Margin    = new Extents(10, 10, 10, 10),
            };

            // Initialize Button2
            Button2 = new Button()
            {
                BackgroundColor     = new Color(0.25f, 0.25f, 0.25f, 1.0f),
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.WrapContent,
                Text      = "Just",
                TextColor = Color.White,
                Margin    = new Extents(10, 10, 10, 10),
            };

            // Initialize Button3
            Button3 = new Button()
            {
                BackgroundColor     = new Color(0.25f, 0.25f, 0.25f, 1.0f),
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.WrapContent,
                Text      = "Align",
                TextColor = Color.White,
                Margin    = new Extents(10, 10, 10, 10),
            };

            // Initialize Button4
            Button4 = new Button()
            {
                BackgroundColor     = new Color(0.25f, 0.25f, 0.25f, 1.0f),
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.WrapContent,
                Text      = "Wrap",
                TextColor = Color.White,
                Margin    = new Extents(10, 10, 10, 10),
            };

            // Add Buttons to parent view
            ButtonView.Add(Button1);
            ButtonView.Add(Button2);
            ButtonView.Add(Button3);
            ButtonView.Add(Button4);

            // Register button click events
            Button1.ClickEvent += Button1Clicked;
            Button2.ClickEvent += Button2Clicked;
            Button3.ClickEvent += Button3Clicked;
            Button4.ClickEvent += Button4Clicked;
        }