How to position element at the bottom of a screen using RelativeLayout's constraints? Currently, I'm using this code:
<Image x:Name="img" Opacity="1"
VerticalOptions="EndAndExpand"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent, Property=Height}"/>
To set a picture as a background, however I need it to start from the bottom, therefore, I need to position it at the bottom. How should I do that? I haven't found any examples of that in the internet. Thanks in advance!
You can use the RelativeView as your container. The make it FillAndExpand in both Horizontal Options and Vertical Options. So now your screen size is the size of your relative layout.
Now you have an image starting at the left bottom and full width :
<Image x:Name="img" Opacity="1"
VerticalOptions="EndAndExpand"
RelativeLayout.WidthConstraint=
"{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.HeightConstraint=
"{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.25}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.75}"/>
Also you can set the Aspect, if your image is of smaller size than the screen.
Aspect - How to size the image within the bounds it is being displayed within (whether to stretch, crop or letterbox).
The Aspect determines how the image will be scaled to fit the display area:
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments