How to create a 1 row and 2 column layout?

BertwinBertwin PHMember ✭✭
edited January 2017 in Xamarin.Forms

Hi! i would like to ask if how can i achieve this kind of layout..
please see attached file... thank you

height should be equally divided into two column..

Best Answers

Answers

  • gdkgdk INMember ✭✭✭

    Hi, You have to set Grid for that type of design. you can take single column defination and two row definations for that grid. using this type of layout you can devided height equally. try with this following code.

    sample code:

       <Grid>
          <Grid.ColumDefination >
                <ColumnDefination Width = "Auto"/>
          </Grid.ColumnDefination>
    
          <Grid.RowDefination >
                    <RowDefination Height = "Auto"/>
                    <RowDefination Height = "Auto"/>
          </Grid.RowDefination>
    
             <StackLayout VerticalOptions="CenterAndExpand">
                <Label Text = "Text1" Grid.Column = "0" Grid.Row = "0" BackGroundColor = "set your required color"/>
                <Label Text = "Text2" Grid.Column = "0" Grid.Row = "1" BackGroundColor = "set your required color"/>
             </StackLayout>
       </Grid>
    
  • seanydaseanyda GBMember ✭✭✭✭✭
    Grid g = new Grid
                {
                    RowDefinitions = {
                        new RowDefinition { Height = new GridLength(1, GridUnitType.Star)}
                    },
                    ColumnDefinitions = {
                        new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star)},
                        new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star)}
                    }
                };
    
Sign In or Register to comment.