flutter - 如何在 Flutter 的 Stack 中实现负责任的容器?
问题描述
所以这里堆放了两个容器。第一个容器有一个背景图像。第二个容器具有固定容器大小的文本。但如果屏幕大小不同,第二个容器文本看起来就不好。所以应该按照规定负责1st container
。有什么方法可以定义它像,1st container
应该有70%
和2nd container
应该有的30%
占用吗?
Stack(
children: [
Container(
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(backgroudImg),
fit: BoxFit.cover,
),
)),
Positioned(
left: 0,
right: 0,
bottom: 0,
child: Container(
height: 45,
color: const Color(0xFF0E3311).withOpacity(0.5),
child: Text(title),
),
)
,
],
)
解决方案
Container(
height: "your height",
width: "your width",
decoration: BoxDecoration(
borderRadius: BorderRadius.circular("INT 15 or 20 your choice"),
image: DecorationImage(
image: NetworkImage(backgroudImg),
fit: BoxFit.cover,
),
)),
child: Stack(
children: [
Align(
child: Alignment.bottomCenter or bottom,
child : Container(
height: "your height",
width: "your width",
decoration : BoxDecoration(
borderRadius: BorderRadius.only(bottomleft and bottomright)
),
child: Center(
child: Text(""))))]))
推荐阅读
- python - psycopg2 使用多个线程或进程处理游标结果
- android - 在文本字段旁边显示图标
- web - 将参数从 Web 应用程序传递到 Unified Service Desk 内的 CRM 案例屏幕
- performance - WhatsApp 如何如此快速地显示讨论?
- magento2 - Magento 2 重新索引过程卡在 Category Products 和 Product Categories
- python - 为什么numpy的转置()结合日期时间
- php - 使用 php,mysql 从数据库中的电子邮件列表发送电子邮件
- project-reactor - 如何在 r2dbc 中加入表?
- node.js - 如何在 github 操作的特定文件夹中运行我的 CI 步骤
- apache-curator - 线程“主”java.lang.NoSuchMethodError 中的异常:org.apache.curator.CuratorZookeeperClient。
例外