Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 自定义ListView文本始终相互重叠_Java_Android_Android Layout_Android Listview_Android Xml - Fatal编程技术网

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>