android - Gridview Flutter 中的 BoxDecoration 溢出
问题描述
在这个gridview中,我将图像和文本放在围绕buy boxdirection的列中,但有时如果图像尺寸更大或文本更大并且来到第二行,那么底部会发生溢出
这是我的代码,请提出一些解决方法
Expanded(
child: Padding(
padding: EdgeInsets.only(bottom: 10,left: 15,right: 10),
child: GridView.count(
crossAxisCount: 3,
crossAxisSpacing: 5.0,
mainAxisSpacing: 5.0,
shrinkWrap: true,
children: List.generate(25, (index) {
return Padding(
padding: EdgeInsets.all(3.0),
child: Container(
margin: const EdgeInsets.all(3.0),
padding: const EdgeInsets.all(3.0),
decoration: BoxDecoration(
border: Border.all(
width: 1.0,
color: Color(0xFFF9AD16),
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Image.asset(
"images/register_top_logo.png",
height: 50,
width: 50,
),
SizedBox(
height: 10,
),
Text(
"Categoryjkjkj",
style: TextStyle(
color: Color(0xFF0066CB),
fontSize: 20.0,
),
),
],
),
),
);
},
),
),
),
),
这里是屏幕
请提出一些解决这个问题的好方法
解决方案
您可以沿 Image 和 Text 小部件添加 wrap Expanded小部件。适合大文本FittedBox Widget 很有帮助。
children: <Widget>[
Image.asset(
"images/img.jpeg",
height: 50,
width: 50,
fit: BoxFit.contain,
),
SizedBox(
height: 10,
),
Expanded(
child: FittedBox(
fit: BoxFit.contain,
child: Text(
"Categoryjkjkj",
style: TextStyle(
color: Color(0xFF0066CB),
fontSize: 20.0,
),
),
),
),
],
推荐阅读
- reactjs - 更新在 componentDidMount 中获取的数据
- mysql - Mariadb mysql-slow-query.log
- javascript - Query join two table but another table need to be in another inside array
- xamarin.forms - 在 Xamarin Forms 中设置从 Button 派生的自定义视图的样式不会应用文本颜色
- c# - 如何使在 ubuntu 机器上运行的 .net 核心与本地数据库连接
- python - 是否可以将所有图像保存在一个文件夹中以用于 tensorflow 对象检测 API
- ssis - 部署在 azure sql server 中的包失败,因为它无法访问远程 excel 文件
- angular - 如果类型是数字,Angular 6 在 1.0 中显示零
- python - 如何推迟函数的执行?
- python - 索引numpy矩阵