代码之家  ›  专栏  ›  技术社区  ›  MShah

如果内容是按行方向放置的,如何减少flex布局中内容之间的空间?

  •  1
  • MShah  · 技术社区  · 8 年前

    我的问题是: 。

    1. 如何减少两行之间的空间?
    2. 如果项目数小于私密行项目,如何减少项目之间的空间?

    我的XAML代码:

    <flexlayout wrap=“wrap”alignitems=“start”direction=“row”justfycontent=“spacearound”horizontaloptions=“startandexpand”>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    <image source=“icon.png”/>
    </flexlayout>
    

    输出: < BR>

    我想要的是: < BR> .

    我的XAML代码:

     <FlexLayout Wrap="Wrap" AlignItems="Start" Direction="Row" JustifyContent="SpaceAround"  HorizontalOptions="StartAndExpand">
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
        <Image  Source="icon.png"/>
    </FlexLayout>
    

    输出:
    enter image description here

    我想要的是:

    4 回复  |  直到 7 年前
        1
  •  2
  •   MShah    7 年前

        2
  •  1
  •   Bhargav Rao rlgjr    7 年前
        3
  •  0
  •   uprightbassfan78    8 年前

        4
  •  0
  •   RandomBoy    8 年前

    private void FlexGallery_SizeChanged(object sender, EventArgs e)
        {
            //imageDimension = Math.Round(FlexGallery.Width / 4) ..round it with  desired method
            foreach (var it in documents.OrderBy(a => a.DateCreated))
            {
                if (Path.GetExtension(it.Url) == ".png" || Path.GetExtension(it.Url) == ".jpg")
                {
                    Image img = new Image
                    {
                        HeightRequest = imageDimension,
                        WidthRequest = imageDimension,
                        Margin = new Thickness(5, 5, 5, 5),
                        Source = ImageSource.FromUri(new Uri(it.Url))
                    };
    
    
                    FlexGallery.Children.Add(img);
                }
                else
                {
    
                }
            }
    
        }
    

    enter image description here

    推荐文章