【问题标题】:I want to make the container have overflow hidden我想让容器隐藏溢出
【发布时间】:2019-11-13 17:30:19
【问题描述】:

我有一个图像,然后我用变换缩放它,然后我想把它放到容器中,我想要结果是容器会溢出图像的高度

这是代码:

Container(
  child: Transform.scale(
  scale: 1.8,
  child: Image(
    image: AssetImage("lib/assets/images/example.jpeg"),
  ),
 ),
)

这是结果:

这就是我想要的:

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:
    Container(
            width: MediaQuery.of(context).size.width,
     height: MediaQuery.of(context).size.height*0.5,
      child: Transform.scale(
      scale: 1.8,
      child: Image(
        image: AssetImage("lib/assets/images/example.jpeg"),
      ),
     ),
    )
    

    【讨论】:

    • 一些描述会有所帮助,而不仅仅是代码
    • 好吧,您应该获取设备屏幕尺寸,然后为该容器提供设备宽度和设备高度的一半以获取设备尺寸,您应该使用 MediaQuery
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    • 2020-04-15
    • 1970-01-01
    • 2012-09-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多