Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stick Layout in Xamarin Forms to bottom

I'm making an application in Xamarin forms but I have some trouble sticking a layout to the bottom of the device. I thought an AbsoluteLayout would work, but I cannot grasp how it works. So I made a RelativeLayout which I filled with the elements I wanted to fill but now I cannot seem to get it working on sticking to the bottom of the device at all time.

Below is a screenshot to make things hopefully a little bit more clear. I have a stacklayout which I fill with the headerlayout and the contentlayout. But if I just add the footerlayout to the stacklayout, it will not be sticked to the bottom of the page but (logically) just behind the previous child. Now I think an Absolutelayout would do the trick, but I cannot seem to grasp the functionality and the Layoutflags and bounds of it. Could someone help me out?

My application

like image 505
Huub S Avatar asked Dec 30 '14 17:12

Huub S


People also ask

How do I use absolute layout in xamarin?

An AbsoluteLayout is used to position and size children using explicit values. The position is specified by the upper-left corner of the child relative to the upper-left corner of the AbsoluteLayout , in device-independent units. AbsoluteLayout also implements a proportional positioning and sizing feature.

How do you pass data from ViewModel to view in xamarin forms?

The only way the code behind can interact with a View Model is through binding the View Model to the view. So ViewModel MyViewModel = new ViewModel; this set up the view to know about the View Model.


2 Answers

<StackLayout>   <StackLayout Orientation="Horizontal" VerticalOptions="Start">     <!-- top controls -->   </StackLayout>    <StackLayout VerticalOptions="CenterAndExpand">     <!-- middle controls -->   </StackLayout>    <StackLayout Orientation="Horizontal" VerticalOptions="End">     <!-- bottom controls -->   </StackLayout> </StackLayout> 

Make sure to have no more than one child with Expand options for best performance.

like image 155
Sergey Metlov Avatar answered Sep 24 '22 19:09

Sergey Metlov


You can use VerticalOptions to send layout to bottom.

var stacklayout = new stackLayout() {      VerticalOptions = LayoutOptions.EndAndExpand      Children = {       //your elements      } } 
like image 37
Ricardo Romo Avatar answered Sep 24 '22 19:09

Ricardo Romo