Xamarin.Forms 界面布局

 <!--margin表示控件相对StackLayout的位置是设置组件之间的距离,或者距离父组件边缘的距离,
    他的四个值是左边距,上边距,右边距,下边距  -->
    <!--Padding是设置组件内容与组件边缘的距离,他的四个值是左边距,上边距,右边距,下边距-->
    <!--本实例中如果Margin和Padding在同一层级都是stackLayout的话表现结果应该都是一样的-->
    <!--Orientation 有俩个属性 Horizontal:横向排列,Vertical:竖向排列默认竖向 -->
    <!--HorizontalOptions: 浮动填充的概念,Start左浮动,Center中间浮动,End右浮动.这4个属性控件大小根据内容自动,,
    StartAndExpand 向上填充一行,CenterAndExpand 向中间位置填充一行,EndAndExpand 向下位置填充一行,FillAndExpand 填充全部 -->
    <!--WidthRequest对填充一行的设置无效,HeightRequest对FillAndExpand无效 -->
    <StackLayout Margin="30,35,10,30"  Spacing="20" Orientation="Vertical" >
        <!-- Place new controls here -->
        <!--HorizontalOptions:-->
        <Label Text="开始位置"
           HorizontalOptions="Start"
           BackgroundColor="LightGray" WidthRequest="30" HeightRequest="100" />
        <Label Text="中间"
           HorizontalOptions="Center"
           BackgroundColor="LightGray" />
        <Label Text="结束位置,终点位置"
           HorizontalOptions="End"
           BackgroundColor="LightGray" />
        <Label Text="一行填充完整"
           HorizontalOptions="Fill"
           BackgroundColor="LightGray" HeightRequest="100" WidthRequest="30" />
        <Label Text="StartAndExpand"
           VerticalOptions="StartAndExpand"
           BackgroundColor="LightGray" />
        <Label Text="CenterAndExpand"
           VerticalOptions="CenterAndExpand"
           BackgroundColor="LightGray" />
        <Label Text="EndAndExpand"
           VerticalOptions="EndAndExpand"
           BackgroundColor="LightGray" WidthRequest="30" HeightRequest="100" />
        <Label Text="FillAndExpand"
           VerticalOptions="FillAndExpand"
           BackgroundColor="LightGray" WidthRequest="30" />
    </StackLayout>

猜你喜欢

转载自www.cnblogs.com/wxpMamarinFrom/p/11578275.html