本文介绍了使容器背景透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个看起来像这样的容器

I have a container which look like this

,它具有一些背景色。我希望容器后面的列表应该可见。为容器编写的代码如下:

which has some background color. I want the list behind the container should be visible. The code written for the container is below:

 new Container(
                  margin: EdgeInsets.fromLTRB(50.0, 10.0, 50.0, 10.0),
                  width: _isTextFieldActive ? 150.0 : 80.0,
                  height: 40.0,
                  decoration: new BoxDecoration(
                      color: Color(0xFF98DAFC),
                      borderRadius: new BorderRadius.only(
                          topLeft: Radius.circular(0.0),
                          topRight: Radius.circular(32.0),
                          bottomLeft: Radius.circular(0.0),
                          bottomRight: Radius.circular(32.0))),
                  alignment: Alignment.bottomCenter,
                  child: new Row(
                    children: <Widget>[
                      new Container(
                          width: 40.0,
                          height: 40.0,
                          child: new Checkbox(value: true)),
                      new Container(
                              width: 40.0,
                              height: 40.0,
                              decoration: new BoxDecoration(
                                  color: Color(0xFFDEDEDE),
                                  borderRadius:
                                      new BorderRadius.circular(32.0)),
                              child: new IconButton(
                                icon: Icon(Icons.search),
                               );
                                  }
                                },
                              ))
                    ],
                  ),
                ),

因此,我希望该容器没有背景色,并且该容器后面的列表应该可见

so,i want that container without background color and the list behind the container should visible

如果我删除了上面的代码我得到如下屏幕。

if i remove the above code i am getting the screen as below.

推荐答案

我不确定100%是否是是的,因为我现在无法测试,但我认为问题可能出在保证金属性上。如果我理解正确,则您希望将Container放在底部中心,底部填充为10dp。我会那样做:

I'm not 100% sure whether that's true, because I'm not able to test it right now, but I think the problem might be the margin property. If I understand you right, you want to have the Container in the bottom center with a bottom padding of 10dp. I would do it like that instead:

Align(
  alignment: Alignment.bottomCenter,
  child: Padding(
    padding: const EdgeInsets.only(bottom: 10.0),
    child: Container(
      height: 40.0,
      decoration: BoxDecoration(
        color: Color(0xFF98DAFC),
        borderRadius: const BorderRadius.only(
          topLeft: Radius.circular(0.0),
          topRight: Radius.circular(32.0),
          bottomLeft: Radius.circular(0.0),
          bottomRight: Radius.circular(32.0),
        ),
      ),
      child: ...,
    ),
  ),
)

这篇关于使容器背景透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:58