[英]Why is my Stack clipping the right-hand side of images?
I want to put some text over an image and I thought of using a ClipRRect with a Stack as a child.我想在图像上放一些文本,我想在小时候使用带有堆栈的 ClipRRect。 That way I could stack the images and text on top of each other.
这样我就可以将图像和文本堆叠在一起。 When I do this though, the image gets cut off on the right-hand side.
但是,当我这样做时,图像会在右侧被切断。 Can anyone point out the problem?
任何人都可以指出问题吗?
Link here as I cannot embed images yet在这里链接,因为我还不能嵌入图像
return ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Stack(
children:<Widget>[
Image.network(
listItem.imageUrl,
height: 200.0,
//width: 100.0,
fit: BoxFit.cover
),
]
),
);
The reason why the right side of the image is clipped out is that you are placing a rounding the border of the Stack instead of the Image.图像右侧被剪掉的原因是您放置的是堆栈的边框而不是图像。 This is how you can achieve what you've wanted to do:
这是您实现您想做的事情的方法:
return Stack(
children:<Widget>[
ClipRRect(
borderRadius: BorderRadius.circular(8.0),
child: Image.network(
listItem.imageUrl,
height: 200.0,
fit: BoxFit.cover
),
),
Align(alignment:Alignment.bottomCenter,child:Text("Hello World")),
]
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.