我将在我的应用程序中使用数据表。
在我的页面中,我有一个背景,这个数据表应该在一个特定的位置(可能是中心),但我不知道如何为那个(数据表)设置对齐方式。
谁能告诉我如何解决这个问题?
小智 19
要在表格行中垂直对齐文本,您可以使用 TableCell 包裹 Conent 并设置垂直 Alignment 参数:
return TableRow(children: [
TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: Padding(
padding: const EdgeInsets.all(10),
child: Text('Hello World'),
),
),
Run Code Online (Sandbox Code Playgroud)
小智 10
child: Table(
children: [
TableRow(children: [
Center(child: Text("item 1"),),
Center(child: Text("item 2"),),
Center(child: Text("item 3"),),
Center(child: Text("item 4"),),
Center(child: Text("Edit"),),
]),
Run Code Online (Sandbox Code Playgroud)
在职的。
import 'package:flutter/material.dart';
void main() => runApp(new Demo());
class Demo extends StatefulWidget {
@override
_DemoState createState() => _DemoState();
}
class _DemoState extends State<Demo> with TickerProviderStateMixin {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: new Text("table demo"),
),
body: new Container(
child: Center(
child: new Table(
children: const <TableRow>[
TableRow(
children: <Widget>[
Center(child: Text('AAAAAA')), Center(child: Text('B')), Center(child: Text('C')),
],
),
TableRow(
children: <Widget>[
Center(child: Text('BBBB')), Center(child: Text('AAAAAA')), Center(child: Text('vdsvsdvs')),
],
),
TableRow(
children: <Widget>[
Center(child: Text('CCCCCC')), Center(child: Text('F')), Center(child: Text('CG')),
],
),
],
),
),
)
)
);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8770 次 |
| 最近记录: |