Last active
July 1, 2016 16:45
-
-
Save saamerm/ea84e94dcbda867bbf9b1460f0fdea74 to your computer and use it in GitHub Desktop.
Using Relative Layout with an alternate method of calling the class.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Xamarin.Forms; | |
namespace App6 | |
{ | |
public class App : Application | |
{ | |
public App() | |
{ | |
MainPage = new RelativeLayoutExample(); | |
} | |
} | |
public class RelativeLayoutExample : ContentPage | |
{ | |
public RelativeLayoutExample() | |
{ | |
this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); | |
Label heading = new Label {Text = "RelativeLayout Example",TextColor = Color.Red,}; | |
Label relativelyPositioned = new Label{Text = "Positioned relative to my parent."}; | |
RelativeLayout relativeLayout = new RelativeLayout(); | |
relativeLayout.Children.Add(heading, Constraint.RelativeToParent((parent) => { | |
return 0; | |
})); | |
relativeLayout.Children.Add(relativelyPositioned, | |
Constraint.RelativeToParent((parent) => { | |
return parent.Width / 3; | |
}), | |
Constraint.RelativeToParent((parent) => { | |
return parent.Height / 2; | |
})); | |
this.Content = relativeLayout; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Relative Layout screenshot