Flutter 颤振如何设置堆栈小部件子项的顶部、中心和底部
如何设置堆栈三的子级, 1.AspectRatio 2.循环压缩机指示器-中心 3.滑块-底部中心 我尝试过上中对齐和下中对齐,但没有改变, 帮我解决这个问题,我附上了屏幕截图和代码。 它就像底部的youtube视频播放器滑块和中间的播放/暂停Flutter 颤振如何设置堆栈小部件子项的顶部、中心和底部,flutter,Flutter,如何设置堆栈三的子级, 1.AspectRatio 2.循环压缩机指示器-中心 3.滑块-底部中心 我尝试过上中对齐和下中对齐,但没有改变, 帮我解决这个问题,我附上了屏幕截图和代码。 它就像底部的youtube视频播放器滑块和中间的播放/暂停 Stack( alignment: Alignment.center, children: <Widget>[ Container(
Stack(
alignment: Alignment.center,
children: <Widget>[
Container(
color: Colors.black,
child: AspectRatio(
aspectRatio: 16 / 9,
),
),
Container(
alignment: Alignment.center,
child: Center(
child: CircularProgressIndicator(),
),
),
Container(
alignment: Alignment.bottomCenter,
child: Material(
color: Colors.black,
child: SliderTheme(
data: SliderTheme.of(context).copyWith(
activeTrackColor: Colors.red,
inactiveTrackColor: Colors.grey,
trackHeight: 2.5,
thumbColor: Colors.red,
thumbShape: RoundSliderThumbShape(enabledThumbRadius: 5.0),
overlayColor: Colors.purple.withAlpha(32),
overlayShape: RoundSliderOverlayShape(overlayRadius: 5.0),
),
child: Slider(
value: 5,
max: 10,
min: 0,
onChanged: (v) {},
),
),
),
),
],
)
使用堆栈小部件中的定位小部件来获得所需的结果。一个例子如下:
Stack(
children: <Widget>[
Positioned(
top/bottom/left/right // use as desired
child: Container(
color: Colors.black,
child: AspectRatio(
aspectRatio: 16 / 9,
),
),
),
],
);
阅读更多关于定位小部件的信息如果您想让3个小部件一个接一个地对齐,请使用列,而不是堆栈,但我需要覆盖子部件。请检查我附加的ny屏幕截图。在这里,你可以找到circularprogressindicator和滑块在中间,但我想让circularprogressindicator作为中心,滑块作为底部中心@pskink@mihansen3不,使用定位不能设置我想要的,它不准确,给顶部一些值和底部,请参考我的第二个屏幕截图,并给出一些简单的例子