如何使图像居中摆在InParent中

问题描述 投票:0回答:2

面对新的颤动困难,如何在imageView的centerInParent中进行颤动?图像不在中心,我使用了Align,但仍然无法正常工作。以及如何构造这张照片的图像和文字? This is the desired result

enter image description here

顶部图像是所需的结果,底部是当前的结果...请为此提供帮助!

  appBar: PreferredSize(
      preferredSize: Size.fromHeight(45.0),
      child: AppBar(
        leading: Row(
          children: [
            Container(
              child: GestureDetector(
                  onTap: () {/* open left menu */},
                  child: Image.asset("assets/images/ic_title_menu.png", width: 18.0, height: 18.0,)),
              padding: EdgeInsets.fromLTRB(14.0, 14.0, 14.0, 14.0),
            ),
          ],
        ),
        title: Container(
          child: GestureDetector(
            onTap: () {/* open search */},
            child: Image.asset("assets/images/ic_title_search.png", width: 18.0, height: 18.0,)),
        ),
        actions: <Widget>[
          Center(
            child: Container(
              child: Stack(children: <Widget>[
                Align(
                  alignment: Alignment.center,
                  child: Image.network(""),)
              ],),
            ),
          )
        ],
        titleSpacing: 0.0,
        automaticallyImplyLeading: false,
      ),
    ),
flutter flutter-layout
2个回答
0
投票

App Bar具有一个名为centerTitle的属性,它将在Appbar中心添加标题。

 centerTitle: true,

0
投票

我希望这是您想要的东西!

import 'package:flutter/material.dart';

const Color kRed = Colors.red;

class Test extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Row(
              children: <Widget>[
                Icon(
                  Icons.menu,
                  color: kRed,
                  size: 30,
                ),
                SizedBox(width: 10),
                Icon(
                  Icons.search,
                  color: kRed,
                  size: 30,
                )
              ],
            ),
            Text(
              'Test Text',
              style: TextStyle(color: kRed, fontSize: 30),
            ),
            Row(
              children: <Widget>[
                Column(
                  children: <Widget>[
                    Text(
                      'Test Text',
                      style: TextStyle(color: kRed, fontSize: 15),
                    ),
                    Text(
                      'Test Text',
                      style: TextStyle(color: kRed, fontSize: 15),
                    ),
                  ],
                ),
                SizedBox(width: 10),
                Icon(
                  Icons.person,
                  color: kRed,
                  size: 30,
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}

Expected Output

只需将中间的Text Widget替换为Image Widget。并调整您的颜色。

© www.soinside.com 2019 - 2024. All rights reserved.