android - 如何修复布局?

标签 android ios image layout flutter

我有这段代码:

@override
  Widget build(BuildContext context) {
    return new Stack(
      children: <Widget>[
        // The containers in the background
        new Column(
          children: <Widget>[
            new Container(
              height: MediaQuery.of(context).size.height * .65,
              color: const Color.fromRGBO(132, 162, 175, 1.0),
              child: new Column(
                children: [
                  new Image.asset('assets/app_logo_transparent_bg.png',
                  height: 100.0,
                  width: 100.0,
                  fit: BoxFit.fill,
                  ),
                ],
              ),
            ),
            new Container(
              height: MediaQuery.of(context).size.height * .35,
              color: Colors.white,
            )
          ],
        ),
        new Container(
          alignment: Alignment.topCenter,
          padding: new EdgeInsets.only(
              top: MediaQuery.of(context).size.height * .58,
              right: 20.0,
              left: 20.0),
          child: new Container(
            height: 200.0,
            width: MediaQuery.of(context).size.width,
            child: new Card(
              color: Colors.white,
              elevation: 4.0,
            ),
          ),
        )
      ],
    );
  }  

结果是这样的:
https://www.dropbox.com/s/bxsormtht173t9d/Screenshot_20181103-204135.png?dl=0

但我努力做到这一点:
https://www.dropbox.com/s/pgqlcuw28r19jfi/Screenshot_20181103-204559.png?dl=0

那么如何去除这个奇怪的黑框呢?

最佳答案

您需要拉伸(stretch)您的 Column ,将 CrossAxisAlignment.stretch 参数用于 ColumncrossAxisAlignment 字段>.

         @override
          Widget build(BuildContext context) {
            return new Stack(
              children: <Widget>[
                // The containers in the background
                new Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: <Widget>[
                    new Container(

                    ...

关于android - 如何修复布局?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53134950/

相关文章:

html - 为什么对我网站上的某些图像应用了一个奇怪的类?

android - 重复的zip条目[okhttp-2.4.0.jar:com/squareup/okhttp/Address.class]

android - 为什么Android HCE 不支持Mifare Classic 类型?

iphone - IOS 的 XCode 中的预期表达式错误

iOS 9.2 常规设置中缺少配置文件部分

javascript - 在使用 Javascript 上传文件之前显示图像和图像扩展名验证

android - 如何在Android中的字符串中插入新行

c# - Java Android 监听器

javascript - fullpage.js - 在不在 fullpage.js 包装器中的 div 内滚动在 IOS 上是不可能的

c++ - 来自 Mat 图像的 OpenCV 子图像