在Android中,我们可以根据TextView
的大小,使ImageView
尽可能多地填充空间。
<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
(green) 尽可能地填充。
new Column(
children: <Widget>[
new Text('Title',
style: new TextStyle(fontWeight: FontWeight.bold)
),
new Text('Datetime',
style: new TextStyle(color: Colors.grey)
),
],
)
最佳答案
不是 100% 肯定,但我认为您是这个意思。 Expanded 小部件扩展到它可以使用的空间。虽然我认为它在行或列中的行为有点不同。
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)
),
),
],
)
关于flutter - 如何使小部件填充列中的剩余空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49977864/