【问题标题】:How to place 2 images in one place Flutter如何将 2 个图像放在一个地方 Flutter
【发布时间】:2022-01-01 21:09:58
【问题描述】:

我对 Flutter 完全陌生,我必须做这样的事情。

对于第二部分,我的右图是由左图和另一个颜色为蓝色的图像组成的。

不要混淆! 我将以更好的方式解释: 首先,我必须将这两张图片放入 一行(类似于 android 中的 FrameLayout

与 右图由左图另一种颜色的图像(只有一种颜色的图像)制成

我希望你明白了

【问题讨论】:

    标签: flutter image flutter-layout


    【解决方案1】:

    如果您的问题是关于重叠两个小部件,您可以使用Stack 来处理它。

    【讨论】:

    • @AmirAndroidDeveloper 您可以将 Positioned child 用作 Stack 的子项并设置 top, right, ...
    【解决方案2】:

    您可以使用 StackPositioned 来执行此操作: 这是带有图标的示例:

    class StackExample extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new Scaffold(
          appBar: new AppBar(),
          body:  new Container(
            padding: const EdgeInsets.all(8.0),
              height: 500.0,
              width: 500.0,
              // alignment: FractionalOffset.center,
              child: new Stack(
                //alignment:new Alignment(x, y)
                children: <Widget>[
                  new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0)),
                  new Positioned(
                    left: 20.0,
                    child: new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0)),
                  ),
                  new Positioned(
                    left:40.0,
                    child: new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0)),
                  )
    
                ],
              ),
            ),
          )
        ;
      }
    }
    
    
    class StackExample extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return new Scaffold(
          appBar: new AppBar(),
          body:  new Container(
            padding: const EdgeInsets.all(8.0),
              height: 500.0,
              width: 500.0,
              // alignment: FractionalOffset.center,
              child: new Stack(
                //alignment:new Alignment(x, y)
                children: <Widget>[
                  new Container(
                    decoration: new BoxDecoration(
                      borderRadius: BorderRadius.circular(25.0),
                      boxShadow: [
                        new BoxShadow(
                          blurRadius: 5.0,
                          offset: const Offset(3.0, 0.0),
                          color: Colors.grey,
                        )
                      ]
                    ),
                    child: new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0))),
                  new Positioned(
                    left: 20.0,
                    child: new Container(
                      decoration: new BoxDecoration(
                      borderRadius: BorderRadius.circular(25.0),
                      boxShadow: [
                        new BoxShadow(
                          blurRadius: 5.0,
                          offset: const Offset(3.0, 0.0),
                          color: Colors.grey,
                        )
                      ]
                    ),
                      child: new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0))),
                  ),
                  new Positioned(
                    left:40.0,
                    child: new Container(
                      decoration: new BoxDecoration(
                      borderRadius: BorderRadius.circular(25.0),
                      boxShadow: [
                        new BoxShadow(
                          blurRadius: 5.0,
                          offset: const Offset(3.0, 0.0),
                          color: Colors.grey,
                        )
                      ]
                    )
                      ,child: new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0))),
                  )
    
                ],
              ),
            ),
          )
        ;
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-27
      • 1970-01-01
      • 2016-10-07
      • 1970-01-01
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 2010-09-08
      相关资源
      最近更新 更多