本文介绍了改变颤振中图像的纵横比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用抖动,并且试图将图像的宽高比从4:3更改为16:9。我试过使用AspectRatio窗口小部件和FittedBox,但图像仍然保持4:3
I am using flutter and I am trying to change the aspect ratio of an image from 4:3 to 16:9. I have tried using the AspectRatio Widget and also using FittedBox but the image still remains 4:3
我试过使用AspectRatio,将Image上的fit道具更改为覆盖,适合并包含
I have tried using AspectRatio, changing the fit prop on the Image to cover, fit, and contain
Card(elevation: 3.0, child: Column(
children: <Widget>[Container(child:
AspectRatio(aspectRatio: 16.0 / 9.0, child: FittedBox(fit:
BoxFit.contain,
child: Image(image: AssetImage('images/maggie.jpg')),),)
)],
推荐答案
您需要使用 BoxFit.fill
来查看效果, BoxFit.cover
在裁剪图像时也显示相同的效果。也不需要 FittedBox
。
You need to use BoxFit.fill
to see the effect, BoxFit.cover
shows same effect with image cropped. And you also don't need FittedBox
.
Card(
elevation: 3.0,
child: Column(
children: <Widget>[
Container(
child: AspectRatio(
aspectRatio: 16 / 9,
child: Image(
image: AssetImage('images/maggie.jpg'),
fit: BoxFit.fill, // use this
),
),
)
],
),
)
这篇关于改变颤振中图像的纵横比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!