如何使小部件填充列中的剩余空间 [英] How to make a widget fill remaining space in a Column
本文介绍了如何使小部件填充列中的剩余空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Android中,我们可以执行以下操作,以使 ImageView
填充尽可能多的空间,具体取决于 TextView $的大小。 c $ c>。
In Android, we can do the following to make ImageView
to fill as much space as possible depending on the size of the TextView
.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
我们如何在 Flutter
中实现这一目标?假设我需要使 Datetime
(绿色)尽可能多地填充。
How do we achieve this in Flutter
? Assume I need to make Datetime
(green) to fill as much as possible.
new Column(
children: <Widget>[
new Text('Title',
style: new TextStyle(fontWeight: FontWeight.bold)
),
new Text('Datetime',
style: new TextStyle(color: Colors.grey)
),
],
)
推荐答案
不确定100%,但我认为您是这个意思。 Expanded小部件会扩展到它可以使用的空间。虽然我认为它在行或列中的行为有所不同。
Not 100% sure but I think you mean this. The Expanded widget expands to the space it can use. Althought I think it behaves a bit differently in a Row or Column.
new Column(
children: <Widget>[
new Text('Title',
style: new TextStyle(fontWeight: FontWeight.bold)
),
new Expanded(
child: new Text('Datetime',
style: new TextStyle(color: Colors.grey)
),
),
],
)
这篇关于如何使小部件填充列中的剩余空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文