颤振位置固定当量 [英] Flutter position fixed equivalent
本文介绍了颤振位置固定当量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以固定屏幕中无论滚动而保持固定的对象?
类似于CSS固定位置的东西。
解决方案
您可以绝对定位
Is it possible to fix an object in the screen that stays fixed regardless of scrolling?
Something similar to CSS position fixed.
解决方案
You can absolutely position a child of a Stack
widget using the Positioned
widget.
The minimal example below places the red box above the list view, by placing the child in a Positioned widget after the ListView in the Stack's children.
List<String> todos = [...];
return new Stack(
children: <Widget>[
new ListView(
children: todos
.map((todo) => new ListTile(title: new Text(todo)))
.toList(),
),
new Positioned(
left: 30.0,
top: 30.0,
child: new Container(
width: 100.0,
height: 80.0,
decoration: new BoxDecoration(color: Colors.red),
child: new Text('hello'),
)
),
],
);
And here it is inside of a Scaffold
body. If you add more items you'll find that the list scrolls without moving the red box.
这篇关于颤振位置固定当量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文