GridLayout项目未正确对齐(GridLayout Items not aligning correctly)
我有3件物品:
图像视图,TextView和CheckBox
我希望图像视图(信息图标)显示在GridLayout的最左侧,文本显示在屏幕的中心,复选框显示在最右侧,尽管正确设置了我的列如图所示,图像仍然堆叠在彼此的顶部; 有任何想法吗?
custome_row.xml
<?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/customRow" android:layout_width="match_parent" android:layout_height="wrap_content" android:alignmentMode="alignMargins" android:useDefaultMargins="true" android:columnOrderPreserved="false" android:rowCount="2" android:columnCount="3" android:orientation="horizontal"> <ImageView android:id="@+id/rowImage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="0" android:layout_row="0" android:layout_marginTop="6dp" android:src="@drawable/ic_info_outline" /> <TextView android:id="@+id/rowTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/colorPrimary" android:layout_row="0" android:layout_column="2" android:layout_marginLeft="8dp" android:textSize="20dp" /> <CheckBox android:id="@+id/completedCheck" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="2" android:layout_row="0"/> </GridLayout>
I have 3 items:
An image View, a TextView and a CheckBox
I want the Image View(the infor icon) to appear on the far left side of a GridLayout, the text to appear at the center of the screen and the check box to appear on the far right side, despite setting up my columns correctly the images are still stacking ontop of eachother as seen in the picture; any ideas?
custome_row.xml
<?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/customRow" android:layout_width="match_parent" android:layout_height="wrap_content" android:alignmentMode="alignMargins" android:useDefaultMargins="true" android:columnOrderPreserved="false" android:rowCount="2" android:columnCount="3" android:orientation="horizontal"> <ImageView android:id="@+id/rowImage" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="0" android:layout_row="0" android:layout_marginTop="6dp" android:src="@drawable/ic_info_outline" /> <TextView android:id="@+id/rowTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:textColor="@color/colorPrimary" android:layout_row="0" android:layout_column="2" android:layout_marginLeft="8dp" android:textSize="20dp" /> <CheckBox android:id="@+id/completedCheck" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_column="2" android:layout_row="0"/> </GridLayout>
原文:https://stackoverflow.com/questions/49112181
更新时间:2024-02-09 11:02
最满意答案
试试这个查询:
def find_profiles return Profile.all if skills.blank? Profile.joins(:skills) .where('skills.name_en IN (:skills) OR skills.name_ar IN (:skills)', skills: skills_array(skills)) .group('profiles.id') .having('COUNT(skills.id) = ?', skills_array(skills).size) end
Try this query:
def find_profiles return Profile.all if skills.blank? Profile.joins(:skills) .where('skills.name_en IN (:skills) OR skills.name_ar IN (:skills)', skills: skills_array(skills)) .group('profiles.id') .having('COUNT(skills.id) = ?', skills_array(skills).size) end
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
Rails - 通过关联获取has_many =>的名称作为字符串(Rails - Get the name from a has_many => through association as a string)[2024-03-26]
如果我正确理解您的要求,以下代码会有所帮助 result = Baz.reflect_on_all_associations.collect do |association| association.name.to_s if association.options[:class_name].present? end.compact 在您的情况下,上面的代码结果['other_mars'] 。 即它返回使用:class_name键声明的所有associations 。 If I understand y ... -
author.books << Book.where(id: params[:books]) 执行不必要的数据库查询。 您可能需要删除数据库中已有的书籍 books_array = params[:books].split(',') - author.books.pluck(:id) books_array.each do |a| author.author_books.build(book_id: a) end # I assumed author_books is the join table ...
-
Rails为数组中的每个记录添加关联(has_many通过)(Rails add association (has_many through) for each record in array)[2023-12-13]
我刚刚搜索并发现这篇文章 ,这是非常有帮助的。 所以用事务包装你的插入应该会有所帮助。 像这样的东西: ActiveRecord::Base.transaction do tasks.each do |task| task.groups_belonging_to << task_group end end I've just googled and found this post, it is pretty helpful. So wrapping your inserts with ... -
使用数组中的所有字符串搜索has_many关联(Use all strings in an array to search through a has_many association)[2022-10-08]
试试这个查询: def find_profiles return Profile.all if skills.blank? Profile.joins(:skills) .where('skills.name_en IN (:skills) OR skills.name_ar IN (:skills)', skills: skills_array(skills)) .group('profiles.id') .having('COUNT(ski ... -
如何通过与其他属性关联使用has_many(How to use has_many through association with additional attributes)[2023-07-19]
宣布attr_accessible绝对不是attr_accessible 。 这就是你所缺少的。 请记住attr_accessor是attr_accessor回事。 有关这方面的更多信息,请检查: attr_accessor和attr_accessible之间的区别 另外请记住,在Rails 4中不推荐使用attr_accessible以支持强参数 ,有效地将属性的所有白名单从模型移动到控制器。 It's absolutely not beside the point to declare attr_acc ... -
如何使用Sunspot / Solr搜索has_many关联?(How to search in has_many association using Sunspot/Solr?)[2022-03-13]
这很好,问题是STI。 我有一个覆盖用户块的运动员块。 This works fine, the problem was STI. I had an Athlete block that was overriding the User block. -
那么,如果你想要的是显示帖子作者的用户名,例如,你可以做一些类似的东西(未测试,但应该可以): @posts = topic.posts.all(:include => :user) 它应该为所有帖子生成一个请求,为用户生成一个请求,帖子收集应该有用户。 在一个视图(哈姆在这里): - @posts.each do |post| = post.user.name = post.body Well, if what you want is display the user name of the ...
-
Rails:通过表单中的对象ID数组进行has_many关联(Rails: has_many association through array of object IDs from form)[2022-01-30]
这似乎是经典的Has和属于许多情况,因为用户可以“拥有”一个群组并且属于许多群组。 我会做一些事情: class Group < ApplicationRecord belongs_to :user has_many :users_groups has_many :users, through: :users_groups accepts_nested_attributes_for :users end Class User < ApplicationRecord belongs_to ... -
Yii:HAS_MANY搜索(Yii: HAS_MANY search)[2022-09-05]
你实际上需要为有问题的模型声明一个成员变量,这里是User 。 你正在做的是这个(在compare() ): $this->cvLaboralExps ,这里cvLaboralExps只是类的关系,而不是一个可以存储值的变量,因此compare的$value为空。 在比较文档中检查此行,解释第二个参数$value : 如果字符串或数组为空,则不会修改现有搜索条件。 这可以通过为模型声明成员变量并修改compare()调用以使用新变量来避免。 ... class User extends CActiveRec ...