当前位置: 首页>>代码示例>>C#>>正文


C# LinearLayout.SetHorizontalGravity方法代码示例

本文整理汇总了C#中LinearLayout.SetHorizontalGravity方法的典型用法代码示例。如果您正苦于以下问题:C# LinearLayout.SetHorizontalGravity方法的具体用法?C# LinearLayout.SetHorizontalGravity怎么用?C# LinearLayout.SetHorizontalGravity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LinearLayout的用法示例。


在下文中一共展示了LinearLayout.SetHorizontalGravity方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSampleContent

        public override View GetSampleContent(Context context)
        {
            chart = new SfChart(context); ;
            chart.SetBackgroundColor(Color.White);

            chart.PrimaryAxis = new NumericalAxis ();
            chart.SecondaryAxis = new NumericalAxis { };

            var series = new LineSeries
            {
                DataSource = MainPage.GetSeriesData1(),
            };
            chart.Series.Add(series);

            series = new LineSeries
            {
                DataSource = MainPage.GetSeriesData2(),
            };
            chart.Series.Add(series);

            series = new LineSeries
            {
                DataSource = MainPage.GetSeriesData3(),
            };        
            chart.Series.Add(series);

            chart.Behaviors.Add(new ChartTrackballBehavior());

            var label = new TextView(context);;
            label.SetPadding(5, 5, 5, 5);
            label.Text = "Press and hold to enable trackball.";

            var layout = new LinearLayout(context){ Orientation = Android.Widget.Orientation.Vertical };

            var layoutLabel = new LinearLayout(context)
            {
                Orientation = Android.Widget.Orientation.Horizontal,
                LayoutParameters =
                    new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)
            };

            layoutLabel.SetHorizontalGravity(GravityFlags.CenterHorizontal);
            layoutLabel.AddView(label);
            
            layout.AddView(layoutLabel);
            layout.AddView(chart);

            return layout;
        }
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:49,代码来源:Trackball.cs

示例2: GetSampleContent

       public override View GetSampleContent(Context context)
        {
            var chart = new SfChart(context);
            chart.SetBackgroundColor(Color.White);

            var primaryAxis = new CategoryAxis { LabelPlacement = LabelPlacement.BetweenTicks };
            primaryAxis.Title.Text = "Month";
            chart.PrimaryAxis = primaryAxis;

            var secondaryAxis = new NumericalAxis();
            secondaryAxis.Title.Text = "Sales";
            secondaryAxis.LabelStyle.LabelFormat = "$##.##";
            chart.SecondaryAxis = secondaryAxis;

            var columnSeries = new ColumnSeries
            {
                DataSource = MainPage.GetSelectionData(),
                DataMarkerPosition = DataMarkerPosition.Center,
                SelectedDataPointIndex = 2,
                DataPointSelectionEnabled = true,
            };

            columnSeries.DataMarker.ShowLabel = true;
            chart.Series.Add(columnSeries);
            
            chart.Behaviors.Add(new ChartSelectionBehavior());
            chart.SelectionChanged += chart_SelectionChanged;

            label = new TextView(context){ TextSize = 20 };
            label.SetPadding(5, 5, 5, 5);

            var layout = new LinearLayout(context){ Orientation = Android.Widget.Orientation.Vertical };

            var layoutLabel = new LinearLayout(context)
            {
                Orientation = Android.Widget.Orientation.Horizontal,
                LayoutParameters =
                    new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)
            };

            layoutLabel.SetHorizontalGravity(GravityFlags.CenterHorizontal);
            layoutLabel.AddView(label);
            layout.AddView(layoutLabel);
            layout.AddView(chart);

            return layout;
        }
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:47,代码来源:DataPointSelection.cs

示例3: GetSampleContent

       public override View GetSampleContent(Context context)
        {
            var chart = new SfChart(context);
            chart.SetBackgroundColor(Color.White);

            var primaryAxis = new CategoryAxis {LabelPlacement = LabelPlacement.BetweenTicks};
            primaryAxis.Title.Text = "Month";
            chart.PrimaryAxis = primaryAxis;

            var secondaryAxis = new NumericalAxis();
            secondaryAxis.Title.Text = "Sales";
            secondaryAxis.LabelStyle.LabelFormat = "$##.##";
            chart.SecondaryAxis = secondaryAxis;

            var columnSeries = new ColumnSeries
            {
                DataSource = MainPage.GetSelectionData(),
                DataMarkerPosition = DataMarkerPosition.Center,
            };

            chart.Series.Add(columnSeries);
            chart.Behaviors.Add(new ChartZoomPanBehavior {SelectionZoomingEnabled = true, SelectionRectStrokeWidth = 1});

           
            var label = new TextView(context);;
            label.SetPadding(5, 5, 5, 5);
            label.Text = "Pinch to zoom or double tap and drag to select a region to zoom in.";

            var layout = new LinearLayout(context){ Orientation = Android.Widget.Orientation.Vertical };

            var layoutLabel = new LinearLayout(context)
            {
                Orientation = Android.Widget.Orientation.Horizontal,
                LayoutParameters =
                    new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)
            };

            layoutLabel.SetHorizontalGravity(GravityFlags.CenterHorizontal);
            layoutLabel.AddView(label);
            
            layout.AddView(layoutLabel);
            layout.AddView(chart);

            return layout;
        }
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:45,代码来源:ZoomingAndPanning.cs

示例4: GetSampleContent

        public override View GetSampleContent(Context context)
        {
            random = new System.Random();
            LoadData();

            chart = new SfChart(context);
            chart.SetBackgroundColor(Color.White);

            chart.PrimaryAxis = new DateTimeAxis { AutoScrollingDelta = 5, AutoScrollingDeltaType = DateTimeDeltaType.Seconds };
            chart.PrimaryAxis.LabelStyle.LabelFormat = "HH:mm:ss";
            
            var axis = new NumericalAxis {Minimum = 0, Maximum = 100};
            chart.SecondaryAxis = axis;

            var columnSeries = new ColumnSeries {DataSource = data};
            chart.Series.Add(columnSeries);

            chart.Behaviors.Add(new ChartZoomPanBehavior {ScrollingEnabled = true, ZoomingEnabled = false});
            
            UpdateData();

            var label = new TextView(context);
            label.SetPadding(5, 5, 5, 5);
            label.Text = "In this demo, a data point is being added every 500 milliseconds." +
                         " The Chart is then automatically scrolled to display the fixed range of data points at the end." +
                         " You can also pan to view previous data points. In this sample the delta value is 5 seconds.";

            var layout = new LinearLayout(context) { Orientation = Android.Widget.Orientation.Vertical };

            var layoutLabel = new LinearLayout(context)
            {
                Orientation = Android.Widget.Orientation.Horizontal,
                LayoutParameters =
                    new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent)
            };

            layoutLabel.SetHorizontalGravity(GravityFlags.CenterHorizontal);
            layoutLabel.AddView(label);

            layout.AddView(layoutLabel);
            layout.AddView(chart);
            return layout;
        }
开发者ID:IanLeatherbury,项目名称:tryfsharpforms,代码行数:43,代码来源:AutoScrolling.cs

示例5: TabSetup

        void TabSetup(ActionBar.Tab tab, int resID)
        {
            var linLay = new LinearLayout(activity)
            {
                LayoutParameters = new LayoutParams(LayoutParams.WrapContent, 180),
                Orientation = Orientation.Vertical,
            };
            linLay.SetHorizontalGravity(Android.Views.GravityFlags.Center);
            var imageView = new ImageView(activity);
            imageView.SetImageResource(resID);
            imageView.SetPadding(-35, 4, -35, 0);
            imageView.SetMinimumWidth(60);

            var textView = new TextView(activity)
            {
                Text = tab.Text
            };
            linLay.AddView(imageView);
            linLay.AddView(textView);
            tab.SetCustomView(linLay);
        }
开发者ID:nodoid,项目名称:TabBarCustomViews,代码行数:21,代码来源:TabPage.cs

示例6: AddItem

        public void AddItem(string itemID, View item)
        {
            if (this.items.Count == 0)
            {

                item.LayoutParameters = new ViewGroup.LayoutParams(92, 92);
                item.SetPadding(10, 10, 10, 10);

                this.items[itemID] = item;

                LinearLayout firstRow = new LinearLayout(this.Context);
                firstRow.Orientation = Orientation.Horizontal;
                firstRow.SetHorizontalGravity(GravityFlags.Center);
                firstRow.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);

                firstRow.AddView(item);

                this.rows[0] = firstRow;

                this.baseLayout.AddView(firstRow);

            } else
            {

                if (this.items.ContainsKey(itemID))
                {
                    throw new InvalidOperationException("An item with the same key already exists in the scroll view!");
                }//end if

                // Get the last row (LinearLayout)
                int lastRowIndex = this.rows.Keys.Max();
                LinearLayout lastRow = this.rows[lastRowIndex];

                item.LayoutParameters = new ViewGroup.LayoutParams(92, 92);
                item.SetPadding(10, 10, 10, 10);

                this.items[itemID] = item;

                if (lastRow.ChildCount < 3)
                {

                    // Last row still has room
                    lastRow.AddView(item);

                } else
                {

                    LinearLayout newRow = new LinearLayout(this.Context);
                    newRow.Orientation = Orientation.Horizontal;
                    newRow.SetHorizontalGravity(GravityFlags.Center);
                    newRow.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);

                    newRow.AddView(item);

                    this.rows[++lastRowIndex] = newRow;

                    this.baseLayout.AddView(newRow);

                }//end if else

            }//end if else
        }
开发者ID:chimpinano,项目名称:WowZapp-Android,代码行数:62,代码来源:LScrollView.cs

示例7: AddRowToLayout

        void AddRowToLayout(SearchRow item)
        {
            var row = new LinearLayout(context) { Orientation = Orientation.Horizontal };
            row.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
            row.WeightSum = 1;

            row.SetMinimumHeight(PixelConverter.DpToPixels(30));

            LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MatchParent, 0.5f);
            LinearLayout.LayoutParams f = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            var entryHolder = new LinearLayout(context);
            entryHolder.Orientation = Orientation.Horizontal;
            entryHolder.SetHorizontalGravity(GravityFlags.Right);
            entryHolder.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
            entryHolder.ShowDividers = ShowDividers.Middle;
            entryHolder.DividerPadding = 20;
            entryHolder.SetPadding(PixelConverter.DpToPixels(10), 0, 0, 0);

            switch (item.RowType)
            {
                case SearchRowTypes.Heading:
                    row.AddView(Heading(item));

                    break;
                case SearchRowTypes.SearchTerms:
                    EditText searchfield = new EditText(context);
                    searchfield.LayoutParameters = f;
                    searchfield.Hint = string.Format("Search {0}:", this.category.Value);
                    searchfield.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                    searchfield.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));
                    searchfield.SetSingleLine(true);
                    searchfield.InputType = InputTypes.ClassText;
                    row.AddView(searchfield);

                    searchfield.TextChanged += (object sender, TextChangedEventArgs e) =>
                    {
                        AddSearchItem(item.QueryPrefix, e.Text.ToString());
                    };

                    break;
                case SearchRowTypes.PriceDoubleEntry:
                    row.AddView(Title(item));

                    EditText minPricefield = new EditText(context);
                    minPricefield.LayoutParameters = p;
                    minPricefield.Hint = "min";
                    minPricefield.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                    minPricefield.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));
                    minPricefield.SetSingleLine(true);
                    minPricefield.InputType = InputTypes.ClassNumber;
                    entryHolder.AddView(minPricefield);

                    EditText maxPricefield = new EditText(context);
                    maxPricefield.LayoutParameters = p;
                    maxPricefield.Hint = "max";
                    maxPricefield.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                    maxPricefield.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));
                    maxPricefield.SetSingleLine(true);
                    maxPricefield.InputType = InputTypes.ClassNumber;
                    entryHolder.AddView(maxPricefield);

                    minPricefield.TextChanged += (object sender, TextChangedEventArgs e) =>
                    {
                        //TODO: Get this text masking to work correctly
                        //string text = minPricefield.Text;
                        //if (text.Length > 0 && text.Substring(0, 1) == "$")
                        //    minPricefield.Text = text;
                        //else
                        //    minPricefield.Text = "$" + text;

                        AddSearchItem(item.QueryPrefix, e.Text.ToString());
                    };

                    maxPricefield.TextChanged += (object sender, TextChangedEventArgs e) =>
                    {
                        //string text = maxPricefield.Text;
                        //if (text.Length > 0 && text.Substring(0, 1) == "$")
                        //    maxPricefield.SetText(text, null);
                        //else
                        //    maxPricefield.Text = "$" + text;

                        AddSearchItem(item.SecondQueryPrefix, e.Text.ToString());
                    };

                    row.AddView(entryHolder);
                    break;

                case SearchRowTypes.DoubleEntry:
                    row.AddView(Title(item));

                    EditText minfield = new EditText(context);
                    minfield.LayoutParameters = p;

                    minfield.Hint = "min";
                    minfield.SetTextSize(Android.Util.ComplexUnitType.Px, rowHeight * 0.40f);
                    minfield.SetPadding((int)(rowHeight * 0.1), (int)(rowHeight * 0.15), (int)(rowHeight * 0.1), (int)(rowHeight * 0.15));
                    minfield.SetSingleLine(true);
                    minfield.InputType = InputTypes.ClassNumber;
                    entryHolder.AddView(minfield);

//.........这里部分代码省略.........
开发者ID:erdennis13,项目名称:EthansList,代码行数:101,代码来源:SearchOptionsFragment.cs

示例8: Initialize

        void Initialize(KeyValuePair<object,object> title, bool selectedAlready)
        {
            this.Orientation = Orientation.Horizontal;
            this.WeightSum = 1;
            this.LayoutParameters = new ListView.LayoutParams(LayoutParams.MatchParent, PixelConverter.DpToPixels(40));

            var text = new TextView(_context) { Text = (string)title.Key };
            text.SetTextSize(Android.Util.ComplexUnitType.Dip, 20);
            text.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent);

            AddView(text);

            var checkBoxPlacer = new LinearLayout(_context);
            checkBoxPlacer.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
            checkBoxPlacer.SetHorizontalGravity(GravityFlags.Right);

            var checkbox = new CheckBox(_context);

            if (selectedAlready)
                checkbox.Checked = true;

            checkbox.LayoutParameters = new ViewGroup.LayoutParams(LayoutParams.WrapContent, LayoutParams.MatchParent);
            checkbox.SetPadding(0,0, PixelConverter.DpToPixels(15), 0);
            checkBoxPlacer.AddView(checkbox);

            checkbox.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) =>
            {
                Console.WriteLine(e.IsChecked);
                if (ItemSelected != null)
                    ItemSelected(this, e);
            };

            AddView(checkBoxPlacer);
        }
开发者ID:erdennis13,项目名称:EthansList,代码行数:34,代码来源:ComboPickerDialogFragment.cs


注:本文中的LinearLayout.SetHorizontalGravity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。