![](/img/trans.png)
[英]Flutter how to change the background color of a selected tile from a 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.