说明:
我定义了一个标准的appBar,FlatButton和textField。我希望所有元素都具有相同的宽度并垂直对齐。
默认的appBar和TextField具有相同的宽度,但没有我的按钮。那么,如何使按钮具有与其他元素相同的宽度?
代码:
import 'package:flutter/material.dart';
/// Styles
class Homepage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Test", style: TextStyle(color: Colors.white)),
centerTitle: true,
backgroundColor: Colors.black,
),
body: Stack(children: <Widget>[
new Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: SingleChildScrollView(
child: Container(
child: Center(
child: Column(
children: <Widget>[
SizedBox(
height: 50,
),
new ButtonTheme(
//minWidth: 300,
child: FlatButton(
color: Colors.black,
child: Text('Play', style: TextStyle(fontSize: 18, color: Colors.white)),
onPressed: () {
// Perform some action
},
),
),
SizedBox(
height: 50,
),
new ListTile(
leading: const Icon(Icons.person),
title: new TextField(
decoration: new InputDecoration(
hintText: "Name Player 1",
),
),
),
],
),
),
),
),
),
]),
);
}
}
答案 0 :(得分:0)
使用具有无限宽度的local boostPart = script.Parent
local jump = leaderstats.gold.Value
local boostedJumpPower = jump.Value
local function onPartTouch(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if ( humanoid ) then
boostPart.CanCollide = false
local currentJumpPower = humanoid.JumpPower
if ( currentJumpPower < boostedJumpPower ) then
humanoid.JumpPower = boostedJumpPower
wait(5)
humanoid.JumpPower = currentJumpPower
end
end
end
boostPart.Touched:Connect(onPartTouch)
来使SizedBox
填充水平空间,然后将其包裹在FlatButton
中(Padding
的填充为16):
AppBar