Make container background as transparent?

筅森魡賤 提交于 2019-12-12 17:50:20

问题


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.


回答1:


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: ...,
    ),
  ),
)


来源:https://stackoverflow.com/questions/51837717/make-container-background-as-transparent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!