繁体   English   中英

如何更改 ListTile 的背景颜色?

[英]How to change background color of ListTile?

我正在制作设置页面,想要制作像 iOS 设置(灰色背景和白色瓷砖)。 我尝试添加容器,以便可以向 ListTile 添加颜色,但总是出错。

有人知道如何在此处添加容器吗?

  body: new SingleChildScrollView(

        child: Column(

          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[

               Column(

                children: <Widget>[

                  ListTile(
                    leading: Icon(
                      Icons.person,
                      color: Colors.grey,
                    ),
                    title: Text("Account"),
                    trailing: Icon(Icons.keyboard_arrow_right),
                  ),

只需将ListTile包装在Container

  Container(
        color: Colors.grey[200],
        child: ListTile(
          leading: Icon(
            Icons.person,
            color: Colors.grey,
          ),
          title: Text("Account"),
          trailing: Icon(Icons.keyboard_arrow_right),
        ),
      )

我用Material小部件包装ListTile并设置颜色。 这将保留 listTile 的涟漪效应。

例如。

Material(
        color: Colors.grey[300],
              child: ListTile(
                title: Text('Hello')
              )

    );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM