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


C# RelativeLayout类代码示例

本文整理汇总了C#中RelativeLayout的典型用法代码示例。如果您正苦于以下问题:C# RelativeLayout类的具体用法?C# RelativeLayout怎么用?C# RelativeLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: OrderListHeaderView

        public OrderListHeaderView()
        {
            HeightRequest = Sizes.LargeRowHeight;

            #region add new order image
            AddNewOrderImage = new Image()
            {
                Aspect = Aspect.AspectFit
            };
            Device.OnPlatform(
                iOS: () => AddNewOrderImage.Source = new FileImageSource(){ File = "add_ios_blue" }, 
                Android: () => AddNewOrderImage.Source = new FileImageSource() { File = "add_android_blue" }
            );

            AddNewOrderImage.IsVisible = Device.OS != TargetPlatform.Android;
            #endregion

            #region add new order label
            AddNewOrderTextLabel = new Label
            {
                Text = TextResources.Customers_Orders_NewOrder.ToUpper(),
                TextColor = Palette._004,
                XAlign = TextAlignment.Start,
                YAlign = TextAlignment.Center,
            };
            #endregion

            #region compose view hierarchy
            BoxView bottomBorder = new BoxView() { BackgroundColor = Palette._013, HeightRequest = 1 };

            const double imagePaddingPercent = .35;

            RelativeLayout relativeLayout = new RelativeLayout();

            relativeLayout.Children.Add(
                view: AddNewOrderImage,
                yConstraint: Constraint.RelativeToParent(parent => parent.Height * imagePaddingPercent),
                xConstraint: Constraint.RelativeToParent(parent => parent.Height * imagePaddingPercent),
                widthConstraint: Constraint.RelativeToParent(parent => parent.Height - (parent.Height * imagePaddingPercent * 2)),
                heightConstraint: Constraint.RelativeToParent(parent => parent.Height - (parent.Height * imagePaddingPercent * 2)));

            relativeLayout.Children.Add(
                view: AddNewOrderTextLabel,
                xConstraint: Constraint.RelativeToView(AddNewOrderImage, (parent, view) => view.X + (view.Width / 2) + parent.Height * imagePaddingPercent),
                widthConstraint: Constraint.RelativeToView(AddNewOrderImage, (parent, view) => parent.Width - view.Width),
                heightConstraint: Constraint.RelativeToParent(parent => parent.Height)
            );

            relativeLayout.Children.Add(
                view: bottomBorder,
                yConstraint: Constraint.RelativeToParent(parent => parent.Height - 1),
                widthConstraint: Constraint.RelativeToParent(parent => parent.Width),
                heightConstraint: Constraint.Constant(1)
            );
            #endregion

           
            Content = relativeLayout;

        }
开发者ID:rsaggio,项目名称:app-crm,代码行数:60,代码来源:OrderListHeaderView.cs

示例2: Initialize

		void Initialize ()
		{
			this.LayoutParameters = new RelativeLayout.LayoutParams(-1,Configuration.getHeight (412));// LinearLayout.LayoutParams (Configuration.getWidth (582), Configuration.getHeight (394));
			this.SetGravity(GravityFlags.Center);


			image = new RelativeLayout(context);
			txtDescription = new TextView (context);
			txtTitle = new TextView (context);
			background = new LinearLayout (context);

			image.SetGravity (GravityFlags.Center);
			background.LayoutParameters = new LinearLayout.LayoutParams (Configuration.getWidth (530), Configuration.getHeight (356));
			background.Orientation = Orientation.Vertical;
			background.SetBackgroundColor (Color.ParseColor ("#50000000"));

			image.LayoutParameters = new RelativeLayout.LayoutParams (Configuration.getWidth (582), Configuration.getHeight (394));

			txtTitle.SetTextColor (Color.ParseColor("#ffffff"));
			txtDescription.SetTextColor(Color.ParseColor("#ffffff"));
			txtTitle.SetTextSize (ComplexUnitType.Px, Configuration.getHeight (40));
			txtDescription.SetTextSize (ComplexUnitType.Px, Configuration.getHeight (30));

			background.AddView (txtTitle);
			background.AddView (txtDescription);



			image.AddView (background);

			this.AddView (image);
			//this.AddView (background);


		}
开发者ID:Milton761,项目名称:MLRepo,代码行数:35,代码来源:CustomerImageView.cs

示例3: GetView

		public override View GetView(Context context, View convertView, ViewGroup parent)
        {
			var view = convertView as RelativeLayout;
			
			if (view == null)
				view = new RelativeLayout(context);
						
            var parms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                        ViewGroup.LayoutParams.WrapContent);
            parms.SetMargins(5, 3, 5, 0);
            parms.AddRule((int) LayoutRules.AlignParentLeft);

            _caption = new TextView(context) {Text = Caption, TextSize = 16f};
            view.AddView(_caption, parms);

            if (!string.IsNullOrEmpty(Value))
            {
                var tparms = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                             ViewGroup.LayoutParams.WrapContent);
                tparms.SetMargins(5, 3, 5, 0);
                tparms.AddRule((int) LayoutRules.AlignParentRight);

                _text = new TextView(context) {Text = Value, TextSize = 16f};
                view.AddView(_text, tparms);
            }

            return view;
        }
开发者ID:xlvisuals,项目名称:MonoDroid.Dialog,代码行数:28,代码来源:StringElement.cs

示例4: ContentDemo

        public ContentDemo()
        {
            Button button = new Button
            {
                Text = "Edit Profile",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            button.Clicked += OnButtonClicked;

            Image myImage = new Image
            {
                Aspect = Aspect.Fill,
                Source = ImageSource.FromUri( new Uri(@"https://4e72eb44013d543eb0c67f8fbddf2ed30743ec8d.googledrive.com/host/0B70CO9lnNPfceHNFLXh2Wm8yMHc/List-Most-Expensive-Cars-photo-OdYL.jpg"))
            };
            this.Title = "Content Page";

            RelativeLayout relativeLayout = new RelativeLayout ();

            relativeLayout.Children.Add (myImage,
                Constraint.Constant (0),
                Constraint.Constant (0),
                Constraint.RelativeToParent ((parent) => { return parent.Width; }),
                Constraint.RelativeToParent ((parent) => { return parent.Height; }));

            relativeLayout.Children.Add (button,
                Constraint.RelativeToParent ((parent) => {return parent.Width/2;} ),
                Constraint.RelativeToParent ((parent) => {return parent.Height/2;} ),
                Constraint.RelativeToParent ((parent) => { return 75.0; }),
                Constraint.RelativeToParent ((parent) => { return 75.0; }));

            Content = relativeLayout;
        }
开发者ID:ctsxamarintraining,项目名称:cts440202,代码行数:33,代码来源:ContentDemo.cs

示例5: RelativeLayoutDemoCode

		public RelativeLayoutDemoCode ()
		{
			Title = "Relative Layout Demo - C#";
			outerLayout = new AbsoluteLayout ();
			layout = new RelativeLayout ();
			centerLabel = new Label { FontSize = 20, Text = "RelativeLayout Demo"};
			buttonLayout = new AbsoluteLayout ();
			box = new BoxView { Color = Color.Blue, HeightRequest = 50, WidthRequest = 50 };
			layout.Children.Add (box, Constraint.RelativeToParent ((parent) => {
				return (parent.Width * .5) - 50;
			}), Constraint.RelativeToParent ((parent) => {
				return (parent.Height * .1) - 50;
			}));
			layout.Children.Add (centerLabel, Constraint.RelativeToParent ((parent) => {
				return (parent.Width * .5) - 50;
			}), Constraint.RelativeToParent ((parent) => {
				return (parent.Height * .5) - 50;
			}));
			moveButton = new Button { BackgroundColor = Color.White, FontSize = 20, TextColor = Color.Lime, Text = "Move", BorderRadius = 0};
			buttonLayout.Children.Add (moveButton, new Rectangle(0,1,1,1), AbsoluteLayoutFlags.All);
			outerLayout.Children.Add (layout, new Rectangle(0,0,1,1), AbsoluteLayoutFlags.All);
			outerLayout.Children.Add (buttonLayout, new Rectangle(0,1,1,50), AbsoluteLayoutFlags.PositionProportional|AbsoluteLayoutFlags.WidthProportional);

			moveButton.Clicked += MoveButton_Clicked;
			x = 0f;
			y = 0f;
			Content = outerLayout;
		}
开发者ID:RickySan65,项目名称:xamarin-forms-samples,代码行数:28,代码来源:RelativeLayoutDemoCode.cs

示例6: AddSpinner

        public void AddSpinner(ViewGroup rootview,string loadingtext)
        {
            loading = true;
            if(loadingcontainer==null||(loadingcontainer!=null&&!loadingcontainer.IsShown)){
                loadingcontainer = new RelativeLayout (nn_activity);
                loadingcontainer.LayoutParameters = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
                loadingcontainer.SetBackgroundColor (Color.White);

                var detailcontainer = new LinearLayout (nn_activity);

                detailcontainer.Orientation = Orientation.Vertical;
                RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams ((int)TapUtil.dptodx (100), RelativeLayout.LayoutParams.WrapContent);
                param.AddRule (LayoutRules.CenterInParent);
                detailcontainer.LayoutParameters = param;

                LinearLayout.LayoutParams linearlayoutparm = new LinearLayout.LayoutParams (LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
                linearlayoutparm.Gravity = GravityFlags.CenterHorizontal;

                ProgressBar progressbar = new ProgressBar (nn_activity);
                progressbar.LayoutParameters = linearlayoutparm;

                TextView tectview = new TextView (nn_activity);
                tectview.LayoutParameters = linearlayoutparm;
                tectview.Text = loadingtext;
                tectview.Gravity = GravityFlags.CenterHorizontal;

                detailcontainer.AddView (progressbar);
                detailcontainer.AddView (tectview);

                loadingcontainer.AddView (detailcontainer);
                rootview.AddView (loadingcontainer);
            }
        }
开发者ID:MADMUC,项目名称:TAP5050,代码行数:33,代码来源:Tap5050Fragment.cs

示例7: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            ActionBar.Hide();
            SetContentView(Resource.Layout.Main);
            cover = FindViewById<RelativeLayout>(Resource.Id.titleScreen);
            player = MediaPlayer.Create(this, Resource.Raw.avril_14th);
            toggleMusic = FindViewById<ToggleButton>(Resource.Id.toggleMusic);
            player.Start();
            player.Looping = true;

            cover.Click += delegate
            {
                StartActivity(typeof(Login));
            };


            toggleMusic.Click += (o, s) =>

            {
                if (toggleMusic.Checked)
                {
                    player.Start();
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPause);

                }
                else
                {
                    toggleMusic.SetBackgroundResource(Android.Resource.Drawable.IcMediaPlay);
                    player.Pause();
                }
            };


        }
开发者ID:knervous,项目名称:MemoryBox,代码行数:35,代码来源:MainActivity.cs

示例8: MyRelativeLayout

		public MyRelativeLayout ()
		{
			var red = new Label {
				Text = "Stop", 
				BackgroundColor = Color.Red,
				Font = Font.SystemFontOfSize (20), 
				WidthRequest = 200, HeightRequest = 30
			};
			var yellow = new Label {
				Text = "Slow down", 
				BackgroundColor = Color.Yellow,
				Font = Font.SystemFontOfSize (20),
				WidthRequest = 160, HeightRequest = 160
			};
			var green = new Label {
				Text = "Go", 
				BackgroundColor = Color.Green,
				Font = Font.SystemFontOfSize (20),
				WidthRequest = 50, HeightRequest = 50
			};

			var relLayout = new RelativeLayout (); 
//			relLayout.Children.Add (red, new Point (20, 20));
//			relLayout.Children.Add (yellow, new Point (40, 60));
//			relLayout.Children.Add (green, new Point (80, 180));
//
			Content = relLayout;
		}
开发者ID:BobSchlitten,项目名称:xamarin-forms-samples,代码行数:28,代码来源:MyRelativeLayout.cs

示例9: MainViewModel

		public MainViewModel (RelativeLayout mainLayout, Context context)
		{
			_webService = ColorWebServices.Instance;
			_shapeFactory = ShapeFactory.Instance;
			_mainLayout = mainLayout;
			_context = context;
		}
开发者ID:jessejiang0214,项目名称:SwitchMediaTest,代码行数:7,代码来源:MainViewModel.cs

示例10: NavigationInfoButtonLayout

		public NavigationInfoButtonLayout ()
		{
			Image = new Image {
				Source = "vraagteken.png",
				Aspect = Aspect.AspectFill,
				Scale = 0.5
			};

			Button = new Button {
				BackgroundColor = Color.Transparent
			};

			var relativeLayout = new RelativeLayout {
				HeightRequest = 50,
				WidthRequest = 50
			};

			relativeLayout.Children.Add (Image,
				Constraint.Constant (0),
				Constraint.Constant (0),
				Constraint.RelativeToParent ((parent) => parent.Width),
				Constraint.RelativeToParent ((parent) => parent.Height));

			relativeLayout.Children.Add (Button,
				Constraint.Constant (0),
				Constraint.Constant (0),
				Constraint.RelativeToParent ((parent) => parent.Width),
				Constraint.RelativeToParent ((parent) => parent.Height));
			
			Children.Add (relativeLayout);
		}
开发者ID:RoyStobbelaar,项目名称:MedewerkerTemp,代码行数:31,代码来源:NavigationInfoButtonLayout.cs

示例11: RippleButton

		/// <summary>
		/// Initializes a new instance of the <see cref="NControl.Controls.RippleButton"/> class.
		/// </summary>
		public RippleButton()
		{            
            _layout = new RelativeLayout {IsClippedToBounds = true};

			// Add ripple thing
			_rippler = new RippleControl{
				InputTransparent = true,
			};
			_layout.Children.Add (_rippler, () => _layout.Bounds);

			// Add title and icon
            _labelText = new Label{ 
				BackgroundColor = Color.Transparent,
				XAlign = TextAlignment.Center,
				YAlign = TextAlignment.Center,
				TextColor = Color.Black,				
				InputTransparent = true,
			};
			
			_layout.Children.Add (_labelText, ()=> GetTextRectangleForImagePosition(_layout));

            _iconLabel = new FontAwesomeLabel{ 
				BackgroundColor = Color.Transparent,
				FontSize = 18,
				TextColor = (Color)IconColorProperty.DefaultValue,
				InputTransparent = true,
			};
			
			_layout.Children.Add (_iconLabel, () => GetIconRectangleForImagePosition(_layout));

			Content = _layout;
		}
开发者ID:patridge,项目名称:NControl.Controls,代码行数:35,代码来源:RippleButton.cs

示例12: XFPage3

        public XFPage3()
        {
            var layout = new RelativeLayout();
            var label = new Label()
            {
                Text = "This is a line of text!"
            };
            layout.Children.Add(label, Constraint.Constant(0),
                Constraint.RelativeToParent(parent => parent.Height / 2));

            var label2 = new Label() { Text = "More text over here!" };

            layout.Children.Add(label2, Constraint.RelativeToView(label, (parent, otherView) => otherView.X + otherView.Width), Constraint.RelativeToView(label, (parent, otherView) => otherView.Y - otherView.Height));

            var label3 = new Label() { Text = "Final text" };

            layout.Children.Add(label3, Constraint.RelativeToView(label2, (parent, otherView) =>
            {
                return (otherView.X + otherView.Width) - label3.Width;
            }),
                Constraint.RelativeToView(label, (parent, otherView) => { return otherView.Y; }));

            label3.SizeChanged += (o, e) => { layout.ForceLayout(); };

            Content = layout;
        }
开发者ID:mkonkolowicz,项目名称:KnockKnock,代码行数:26,代码来源:XFPage3.cs

示例13: HomeButton

        public HomeButton(string iconText, string title, Color iconBGColor, Color titleBGColor)
        {
            IconLabel iconLabel = new IconLabel {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions = LayoutOptions.Fill,
                BackgroundColor = iconBGColor,
                TextColor = Color.White,
                Text = iconText,
                FontSize = 60
            };

            Label titleLabel = new Label {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions = LayoutOptions.Fill,
                BackgroundColor = titleBGColor,
                TextColor = Color.White,
                Text = title,
                FontSize = 14
            };

            RelativeLayout layout = new RelativeLayout ();
            layout.Children.Add (iconLabel,
                Constraint.Constant (0),
                Constraint.Constant (0),
                Constraint.RelativeToParent ((parent) => parent.Width),
                Constraint.RelativeToParent ((parent) => parent.Height));

            layout.Children.Add (titleLabel,
                Constraint.Constant (0),
                Constraint.RelativeToParent ((parent) => parent.Height * 0.75),
                Constraint.RelativeToParent ((parent) => parent.Width),
                Constraint.RelativeToParent ((parent) => parent.Height * 0.25));

            Content = layout;
        }
开发者ID:DaveCaldeira,项目名称:NavigationTest,代码行数:35,代码来源:HomeButton.cs

示例14: CardView

		public CardView()
		{
			HeightRequest = 6*UiConst.LINE_HEIGHT;
			WidthRequest = 320;
			BackgroundColor = Color.Maroon;
			Padding = new Thickness(2);

			var t = new TapGestureRecognizer();
			t.Tapped += new DenyAction<object, EventArgs>(MAnimation, 800).OnEvent;
			GestureRecognizers.Add(t);

			Content = (_rootLayout = new RelativeLayout()
			{
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
				BackgroundColor = UiConst.COLOR_DF_BG
			});

			Content.GestureRecognizers.Add(t);

			// init component
			_rootLayout.Children.Add(new MyLabel
			{
				BackgroundColor = Color.Pink
			}, null, null, null, Constraint.Constant(UiConst.LINE_HEIGHT));
		}
开发者ID:manhvvhtth,项目名称:xm-form,代码行数:26,代码来源:CardView.cs

示例15: OnCreate

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			
			_timestamp = DateTime.Now.ToLongTimeString ();
			
			// create a layout
			var rl = new RelativeLayout (this);
			var layoutParams = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);
			rl.LayoutParameters = layoutParams;
			
			// get the initial orientation
			var surfaceOrientation = this.WindowManager.DefaultDisplay.Rotation;
			
			// create the portrait and landscape layout
			_layoutParamsPortrait = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);		
			_layoutParamsLandscape = new RelativeLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);
			_layoutParamsLandscape.LeftMargin = 100;
			_layoutParamsLandscape.TopMargin = 100;
			
			// create the TextView an assign the initial layout params
			_tv = new TextView (this);
			
			if (surfaceOrientation == SurfaceOrientation.Rotation0 || surfaceOrientation == SurfaceOrientation.Rotation180) {
				_tv.LayoutParameters = _layoutParamsPortrait;
			} else {
				_tv.LayoutParameters = _layoutParamsLandscape;
			}
			
			_tv.Text = "Programmatic layout. Timestamp = " + _timestamp;
			
			rl.AddView (_tv);
	
			SetContentView (rl);
		}
开发者ID:89sos98,项目名称:monodroid-samples,代码行数:35,代码来源:CodeLayoutActivity.cs


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