Java 自定义ListView文本始终相互重叠
我已经做了一个显示数据列表的卡片布局。出于某种原因,无论我更改了布局宽度、高度、重量等哪些属性,文本始终显示在其他文本行的顶部,如下所示 我错过了什么Java 自定义ListView文本始终相互重叠,java,android,android-layout,android-listview,android-xml,Java,Android,Android Layout,Android Listview,Android Xml,我已经做了一个显示数据列表的卡片布局。出于某种原因,无论我更改了布局宽度、高度、重量等哪些属性,文本始终显示在其他文本行的顶部,如下所示 我错过了什么 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_he
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:background="@drawable/card_inset">
<RelativeLayout
android:id="@+id/eventDetails"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="70"
android:orientation="vertical" >
<TextView
android:id="@+id/eventTeams"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textSize="17sp" />
<TextView
android:id="@+id/eventClickForMore"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:textSize="14sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/eventTimeSection"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="30"
android:orientation="vertical" >
<TextView
android:id="@+id/eventTime"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="22sp" />
<TextView
android:id="@+id/eventDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:textAlignment="center"
android:textSize="12sp" />
</RelativeLayout>
您可以在
文本视图中使用id@+id/eventClickForMore
下的android:layout\u
看
在名为eventClickForMore
的文本视图中,将属性android:layout\u添加到=“@+id/eventTeams”
下面
对名为eventDate
的TextView
执行相同的操作,它应该位于eventTime
编辑
我已经更新了代码,基本上,您需要将eventTeams
和eventTimeSection
的layout\u height
属性更改为android:layout\u height=“wrap\u content”
match\u parent
使TextView
垂直占据所有空间
此外,我认为您可以在eventClickForMore
和eventDate
中删除android:layout\u alignParentBottom
和android:layout\u alignParentLeft
(不确定,也许第一次更新就足够了)
请参见下面的我的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:background="@drawable/card_inset">
<RelativeLayout
android:id="@+id/eventDetails"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="70"
android:orientation="vertical" >
<TextView
android:id="@+id/eventTeams"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="17sp" />
<TextView
android:id="@+id/eventClickForMore"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/eventTeams"
android:textSize="14sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/eventTimeSection"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="30"
android:orientation="vertical" >
<TextView
android:id="@+id/eventTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="22sp" />
<TextView
android:id="@+id/eventDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/eventTime"
android:gravity="center"
android:textAlignment="center"
android:textSize="12sp" />
</RelativeLayout>
您不应该将+
放在下面的布局中
如上所述,我这样做了(没有上面评论中提到的+),它实际上似乎隐藏了eventClickForMore和eventDate部分。他们根本看不见。我已经更新了我的帖子,如果你仍然面临这个问题,请告诉我!谢谢工作起来很有魅力!仅仅做出这样的改变实际上似乎就让事件clickformore一起消失了。是否存在与此冲突的其他现有财产?我没有做其他改变。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:background="@drawable/card_inset">
<RelativeLayout
android:id="@+id/eventDetails"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="70"
android:orientation="vertical" >
<TextView
android:id="@+id/eventTeams"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="17sp" />
<TextView
android:id="@+id/eventClickForMore"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/eventTeams"
android:textSize="14sp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/eventTimeSection"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="30"
android:orientation="vertical" >
<TextView
android:id="@+id/eventTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textSize="22sp" />
<TextView
android:id="@+id/eventDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/eventTime"
android:gravity="center"
android:textAlignment="center"
android:textSize="12sp" />
</RelativeLayout>