- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
如何使整个AppBar
居中以及如何减少前导图标?
我尝试使用 Center
小部件和 Column
以及 mainAxisAlignment.center
不工作。我尝试将 width
和 height
添加到前导图标容器中。但没有任何效果
appBar: PreferredSize(
child: AppBar(
leading: Container(
decoration: BoxDecoration(..),
child: Icon(..),
),
title: TextFormField(
...
),
actions: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
...
),
CupertinoSwitch(
...
)
],
)
],
),
preferredSize: Size.fromHeight(80.0)),
最佳答案
作为一个选项
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AwesomeAppBar(height: 80),
),
);
}
}
class AwesomeAppBar extends PreferredSize {
final double height;
const AwesomeAppBar({Key key, @required this.height});
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, snapshot) {
return Container(
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
height: height,
color: Theme.of(context).primaryColor,
child: Row(
children: <Widget>[
Container(
padding: EdgeInsets.all(16),
child: Icon(
Icons.arrow_back,
color: Colors.white,
),
),
Expanded(
child: Container(
height: 32,
alignment: Alignment.centerLeft,
padding: EdgeInsets.symmetric(horizontal: 16),
margin: EdgeInsets.only(right: 16),
decoration: ShapeDecoration(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
color: Colors.white,
),
child: Text('Search'),
),
),
SwitchWithText(),
SizedBox(width: 16),
],
),
);
});
}
@override
Size get preferredSize => Size.fromHeight(height);
}
class SwitchWithText extends StatefulWidget {
@override
_SwitchWithTextState createState() => _SwitchWithTextState();
}
class _SwitchWithTextState extends State<SwitchWithText> {
@override
Widget build(BuildContext context) {
return Row(
children: <Widget>[
Text('Online', style: TextStyle(color: Colors.white)),
CupertinoSwitch(
value: true,
onChanged: (b) {},
activeColor: Colors.lightBlueAccent,
),
],
);
}
}
关于flutter - 如何使 AppBar 居中以及如何减小 PreferredSize 中的前导图标大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57197976/
我正在使用 GridBagLayout Manager 来明确定义标签和 JScrollPane 应该放置的位置(目前)。 我使用 gridbagconstraint 告诉第一个名为“label1”(
JEditorPane 似乎有一个非常有趣的功能:它似乎跟踪其父级宽度,并相应地确定首选高度,即使父级不是 JViewport 也是如此。 通过轨道,我的意思是组件的首选宽度设置为其父级之一(可能除了
我仍在努力学习布局管理器的工作原理。我用两个 JPanel 制作了一个框架。第一个包含带有 boxLayout 的 textArea。第二个包含带有按钮的流布局。 我相应地设置了每个面板的 prefe
我是flutter的新手,我看到很少有用于布局设计的小部件,例如SizedBox和Container。有一个小部件是 PreferredSize 小部件,我不知道并且找不到任何有关它的示例。它与其他可
我想为 MyPanel 添加一个 FlowLayout 来添加一些任意按钮。我将 MyPanel 添加到 JFrame north(JFrame 有一个 BorderLayout)。我的问题是: 当M
有什么方法可以获取 JLabel 组件的(我认为是首选)大小,以便我可以根据它们调整其大小?我的 JLabel 的大小为 0,0 ,除非我设置其首选大小,但将其大小设置为任意像素值似乎是错误的方法,因
我不知道如何使带有 SpringLayout 的 JPanel 正确计算其首选大小,因为目前它始终是 (0, 0)。我尝试调用 panel.setPreferredSize(layout.prefer
有谁知道如何使用 Gridbaglayout 将 ScrollBar 添加到 JPanel,从而允许 Gridbaglayout 仍然在水平轴上重新定位组件。我尝试添加滚动条 - 但是当我执行 Gri
我刚刚注意到 JButton 至少在以下两件事是正确的: 按钮的 preferredSize 属性不是默认值。 按钮的 text 属性不是默认的“”(空)。 可能有其他属性值组合使按钮忽略操作的名称,
如何使整个AppBar居中以及如何减少前导图标? 我尝试使用 Center 小部件和 Column 以及 mainAxisAlignment.center 不工作。我尝试将 width 和 heigh
我正在关注这个 YouTube他们使用的教程Modifier.preferredSize()在一个盒子上和 Modifier.preferredHeight()在 Spacer Composable
我写了一个十六进制查看器。 但是,我发现 Swing 存在局限性。如果您有一个 3GB 文件并且以每行 20 像素进行渲染,则组件的总高度为: (3GB/每行 16 字节)* 每行 20 像素 = 3
我试图理解为什么下面的短代码不起作用。据我所知,当没有布局或组件的大小为0时,不会调用paint组件方法。 但这里的情况并非如此。 你能解释一下为什么我无法为此设置背景吗? public class
我有一个问题,我已经在 eclipse java neon 中编程,并且正在用表做一些事情,并且进入 swing,实际上是 JTable 的组件。现在我需要向表中的组件添加一个图像,我创建了一个名为
我是一名优秀的程序员,十分优秀!