基本上我正在构建一个 ListView 。所以我正在使用卡片,我想要实现的是在卡片中我想划分一个部分来为列着色,另一个部分我想写一个我希望它居中的文本但是我尝试了很多选项不能实现。
我注意到我的颜色没有完全覆盖它外面有一些白色元素。以下是我为实现它所做的完整代码。
我要解决的问题如下
1) To make the color column look clean and neat as the image above because now I tried to adjust its height slight smaller than the card height which is 35
2) The text to be centered
3) The gesture to detect the whole of the text column
4) I have other design where it might have 3 or more column and how to build a separator
5) I have set the card width: 30.0, but it always goes right till the end it never stays at 30.
new Container(
height:190,
child:
new ListView.builder(
shrinkWrap: true,
itemCount: vdata.length,
itemBuilder: (BuildContext ctxt, int index) {
return Container(
margin: new EdgeInsets.fromLTRB(10, 0, 10, 0),
width: 30.0,
height: 35.0,
child: Card(
color: Colors.white,
child: Row (
//mainAxisSize: MainAxisSize.max,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
decoration: new BoxDecoration(
color: Colors.amber,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(5),
bottomLeft: const Radius.circular(5)
),
),
height: 27,
width: 10,
),
],
),
new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
//mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
//new Row(
// mainAxisSize: MainAxisSize.max,
//children: <Widget>[
new GestureDetector(
onTap: () {
setState(() {
_localVehicleSelected=vdata[index]["pr"].toString();
});
doSomething(vdata[index]["pr"].toString());
},
child:new Text('Test Plate',
),
),
//style: Theme.of(context).textTheme.body2
//],
//),
],
),
],
),
)
);
基于已尝试回答的屏幕截图。
最佳答案
您需要使用卡片形状来获得您想要的内容,此外您还需要使用 - crossAxisAlignment: CrossAxisAlignment.center,
Container(
height: 190,
child: new ListView.builder(
shrinkWrap: true,
itemCount: 10,
itemBuilder: (BuildContext ctxt, int index) {
return Container(
margin: new EdgeInsets.fromLTRB(10, 0, 10, 0),
width: 25.0,
height: 55.0,
child: Card(
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.0)),
color: Colors.white,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
color: Colors.amber,
width: 10,
),
SizedBox(
width: 10.0,
),
Expanded(
child: GestureDetector(
onTap: () {
print('testing');
// setState(() {
// _localVehicleSelected =
// vdata[index]["pr"].toString();
// });
//
// doSomething(vdata[index]["pr"].toString());
},
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
//new Row(
// mainAxisSize: MainAxisSize.max,
//children: <Widget>[
new Text(
'Test Plate',
),
//style: Theme.of(context).textTheme.body2
//],
//),
],
),
),
),
],
),
));
}))
关于user-interface - Flutter 卡列对齐和文本居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54949375/
我怎样才能完成http://php.net/manual/en/function.call-user-func-array.php在ruby中?所以我可以这样做:classAppdeffoo(a,b)putsa+benddefbarargs=[1,2]App.send(:foo,args)#doesn'tworkApp.send(:foo,args[0],args[1])#doeswork,butdoesnotscaleendend 最佳答案 尝试分解数组App.send(:foo,*args)
我意识到这可能是一个非常基本的问题,但我现在已经花了几天时间回过头来解决这个问题,但出于某种原因,Google就是没有帮助我。(我认为部分问题在于我是一个初学者,我不知道该问什么......)我也看过O'Reilly的RubyCookbook和RailsAPI,但我仍然停留在这个问题上.我找到了一些关于多态关系的信息,但它似乎不是我需要的(尽管如果我错了请告诉我)。我正在尝试调整MichaelHartl'stutorial创建一个包含用户、文章和评论的博客应用程序(不使用脚手架)。我希望评论既属于用户又属于文章。我的主要问题是:我不知道如何将当前文章的ID放入评论Controller。
Devise是一个Ruby库,它为我提供了这个User类:classUser当写入:confirmable时,注册时会发送一封确认邮件。上周我不得不批量创建300个用户,所以我在恢复之前注释掉了:confirmable几分钟。现在我正在为用户批量创建创建一个UI,因此我需要即时添加/删除:confirmable。(我也可以直接修改Devise的源码,但我宁愿不去调和它)问题:如何即时添加/删除:confirmable? 最佳答案 WayneConrad的解决方案:user=User.newuser.skip_confirmation
我正在尝试运行rakedb:create在DigitalOcean服务器上使用postgresql。但是,它返回错误Peerauthenticationfailedforuser"rails",引用config/database.yml登录凭据的存储位置奇怪的是,当我通过SSH登录服务器时,这些凭据以纯文本形式显示给我。我都试过了密码以纯文本形式显示给我,同样的事情发生了。环境在生产中,我必须手动强制执行,因为应用程序在启动时正在开发中并强制它在config/environments.rb中更改不工作。如果我不得不猜测,我可能会说环境中发生了一些有趣的事情,因为DigitalOcean
如何用HAML编写这个ERB:#OR我可以:=some_ruby_code+":"#and=some_ruby_code%br但我不想在这里连接,我想将它写成内联:(=some_ruby_code):#and(=some_ruby_code)%br 最佳答案 =some_ruby_code+":"-#and=some_ruby_code+""编辑1:我不确定您在寻找什么。你想要其中之一吗?==#{some_ruby_code}:-#and==#{some_ruby_code}或==#{some_ruby_code}:-#and=so
尝试从我的AngularJS端将数据发布到Rails服务器时出现问题。服务器错误:ActionController::RoutingError(Noroutematches[OPTIONS]"/users"):actionpack(4.1.9)lib/action_dispatch/middleware/debug_exceptions.rb:21:in`call'actionpack(4.1.9)lib/action_dispatch/middleware/show_exceptions.rb:30:in`call'railties(4.1.9)lib/rails/rack/logg
我想通过控制台手动创建一个用户:User.find_or_create_by(email:"user@mail.com",first_name:"Stan",last_name:"Smith",password:"password",password_confirmation:"password",confirmed_at:Time.now)我在过去的项目中多次这样做,但这次没有用。它没有获取Devise密码模型属性,所以这是我得到的错误:PG::UndefinedColumn:ERROR:columnusers.passworddoesnotexist我有Rails4.1.4和Dev
我在运行Ubuntu10.04LTS的远程VPS机器上以生产模式运行RubyonRails3.0.9(在开发模式下,我在MACOSSnow上使用RoRLeopard),我想知道如何管理以下场景。我使用Apache2和PhusionPassenger并且我将虚拟主机设置为如下所示:ServerNameproject_name.comDocumentRoot/srv/www/project_name.com/publicAllowOverrideallOptions-MultiViews此外,我使用Paperclipgem,由于网上很多人在生产模式下使用它,我在处理(图像)文件时遇到以下错
我一直在为使用acts_as_list的模型实现一些不错的交互界面,这些界面可以对我的mRails应用程序中的列表进行排序。我有一个排序函数,在每次拖放之后使用sortable_elementscript.aculo.us函数调用并设置每条记录的位置。这是在拖放完成后处理排序的Controller操作示例:defsortparams[:documents].each_with_indexdo|id,index|Document.update_all(['position=?',index+1],['id=?',id])endend现在我正在尝试对嵌套集模型(acts_as_nested
问题localhost:3000/users/不会显示我谦虚地进入,因为我是第一次尝试通过Rails教程。我在第10章,我已经花了5个小时解决这个问题。当我尝试访问localhost:3000/users/时出现错误(我相信这与factory_girl有关)解释了@users变量为空并且我忘记了为will_paginate传递一个集合对象。我目前在第10章第10.23节,每次运行时:$bundleexecrakedb:reset$bundleexecrakedb:populate$bundleexecrakedb:test:prepare我在解释时遇到错误rakeaborted!Fac