如何将容器的高度设置为相对值?

huangapple go评论53阅读模式
英文:

How to set height of container to be of relative value?

问题

以下是翻译好的部分:

有一行包含3个扩展容器;中间容器具有固定高度。

目标是使两端容器的高度隐式匹配中间容器的高度。

可视结构如下:

脚手架:
  行:
    扩展:
      容器(高度:?)
    扩展:
      容器(高度:100)
    扩展:
      容器(高度:?)
英文:

There is a row with 3 expanded containers; the mid-container has a fixed height.

The goal is to make the height of the containers in both ends implicitly match the height of the mid-container.

A visual structure would look as follows:

Scaffold:
  Row:
    Expanded:
      Container(height: ?)
    Expanded:
      Container(height: 100)
    Expanded:
      Cotnainer(height: ?)

答案1

得分: 1

你可以使用 IntrinsicHeight(稍昂贵)

 IntrinsicHeight(
    child: Row(....),
 ),
英文:

You can use IntrinsicHeight(little expensive)

 IntrinsicHeight(
    child: Row(....),
 ),

答案2

得分: 1

移除侧边容器的高度。设置:

Row(
   crossAxisAlignment: CrossAxisAlignment.stretch,
   ...

这将使所有容器伸展以适应最高的容器。

英文:

Remove height from side containers. Set:

Row(
   crossAxisAlignment: CrossAxisAlignment.stretch,
   ...

This will stretch all containers to fit the tallest.

huangapple
  • 本文由 发表于 2023年3月20日 23:53:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75792511.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定