【问题标题】:how do i fill available space in stacklayout?如何填充stacklayout中的可用空间?
【发布时间】:2018-10-22 01:00:40
【问题描述】:

嗨,我需要用水平堆栈布局填充屏幕宽度,但它没有填充

这是我的代码

   <StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">

           <Entry Placeholder="Nombre" FontSize="14" />
           <Entry Placeholder="A. Paterno" FontSize="14" />
           <Entry Placeholder="A. Materno" FontSize="14" />
   </StackLayout>

我已经尝试过使用 Horizo​​ntalOptions = "Fill" 和 "Fill and Expand" 我已经尝试过以这种方式放入 AbsoluteLayout

<AbsoluteLayout>
    <StackLayout Orientation="Horizontal" AbsoluteLayout.LayoutBounds="0,0,1,.2" AbsoluteLayout.LayoutFlags="All"> 
        <Entry Placeholder="Nombre" FontSize="14" />
        <Entry Placeholder="A. Paterno" FontSize="14" />
        <Entry Placeholder="A. Materno" FontSize="14" />
     </StackLayout>
</AbsoluteLayout>

还有什么想法吗?

【问题讨论】:

  • 将 StackLayout 替换为具有一 auto 行和三 1* 列的 Grid。它应该均匀地划分空间。
  • 你想显示所有相同宽度的条目?

标签: xamarin.forms cross-platform


【解决方案1】:

如果您想以相同的宽度显示所有条目并水平填充,请尝试以下代码:

<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand">

            <Entry Placeholder="Nombre" FontSize="14"  HorizontalOptions="StartAndExpand"/>
            <Entry Placeholder="A. Paterno" FontSize="14" HorizontalOptions="CenterAndExpand"/>
            <Entry Placeholder="A. Materno" FontSize="14" HorizontalOptions="EndAndExpand"/>
        </StackLayout>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-02
    • 2013-02-13
    相关资源
    最近更新 更多