android - 为什么文本元素居中以及如何在 Dart 中将其与右侧对齐
问题描述
我有一个应该向左对齐的文本元素,但由于某种原因它看起来居中,我不知道为什么。
应该更改/添加哪些代码以使result
字符串向右对齐?
return Positioned(
bottom: 0,
right: 0,
left: 0,
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
margin: EdgeInsets.fromLTRB(10, 0, 10, 30),
padding: EdgeInsets.all(10),
child: Column(
children: <Widget>[
//First row here. The one below is the second row:
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 5.0),
child: Icon(Icons.comment),
),
Expanded(
child: Column(children: [
Padding(
padding: EdgeInsets.only(
top: 10.0, left: 5.0, right: 0),
child: Text(
result, //This text is centered. Why?
maxLines: 7,
overflow: TextOverflow.ellipsis,
)),
]),
)
],
),
],
)
)
)
);
解决方案
为此,您可以使用方向。
例如:
MaterialApp(
builder: (context, child) {
return Directionality(
textDirection: TextDirection.rtl,
child: child,
);
},
);
推荐阅读
- php - 带有 firebird 和 php 的 Web 服务
- laravel - Laravel:更改数据库中时间戳的名称
- c++ - 是shared_future
条件变量的合法替代品? - python - Numpy 全局保持维度
- javascript - 什么是“PropTypes.oneOf”的 TypeScript 等效项(将变量限制为值的子集)
- google-cloud-platform - 如何让 glusterfs 在集群升级中存活下来
- angular - Datepicker (matCalendar) angular2 应该在滚动页面时移动
- scala - 如何在 slick 中创建多个主键?
- ubuntu - Portaudio 选择用于捕获的输入设备
- javascript - 如何从另一个页面触发视觉力页面中的事件