flutter - 根据 Appbar 高度更改前导和标题
问题描述
return Scaffold(
appBar:
PreferredSize(
preferredSize: Size.fromHeight(120),// change appbar size
child:AppBar(
backgroundColor: Color.fromARGB(255,254,202,8),
leading:RawMaterialButton(
constraints: BoxConstraints(),
padding: EdgeInsets.all(0),
child: Image.asset("assets/img/home.png",height:110), // set height as 110
),
title:Text("mytitle");
我改变了appbar的高度preferredSize
并将前导图像高度设置为100
AppBar 高度已更改,但前导图标大小未更改。
还有文字。
如何根据应用栏大小更改前导和文本大小?
解决方案
无法更改 中的leading
大小AppBar
,但一种解决方法是使用Row
包含图像和标题的 并将此行设置为flexibleSpace
的AppBar
:
AppBar(
backgroundColor: Color.fromARGB(255, 254, 202, 8),
flexibleSpace: Row(
children: <Widget>[
RawMaterialButton(
constraints: BoxConstraints(),
padding: EdgeInsets.all(0),
child: Image.asset(
"assets/img/home.png",
height: 110,
),
),
Text("mytitle"),
],
),
),
推荐阅读
- python - 当参数包含特殊字符或空格时,/profile/preview/ 处的 NoReverseMatch
- android - 带有 MutableContextWrapper VS 片段的自定义视图
- sql - 如何从字符串日期c#中获取年份
- c - 将文本文件读入C中的数组
- java - AndroidStudio 无法运行单个参数化测试
- intel - 英特尔内置显卡 (Intel Iris Plus Graphics 655) 上的 OpenACC
- xero-api - Xero API中发票的Oauth2范围?
- python - 如何在 Python 中通过 imap/pop3 识别 Outlook“消息 ID”?
- java - 当从另一个片段访问时,静态 int 数组元素变为 0
- postgresql - 当我加载我的夹具时表存在时未定义的表_seq