Java Android studio的布局设置如下

Java Android studio的布局设置如下,java,android,layout,android-studio,Java,Android,Layout,Android Studio,我已经尝试了我能想到的一切,但无法让这个布局工作。它是一个列表视图,列表在一行中匹配 第一行是第一个匹配,下一行是第二个匹配,依此类推。我不介意绿色的笔划和边框 有可能吗 请参见此处的设计:您需要一个填充ListView的自定义适配器(最好使用RecyclerView&一个带有ViehHolder的适配器),此行布局取自我自己的项目,并不完全符合您的要求,但您会明白的。请发表评论以获取更多信息 <RelativeLayout xmlns:android="http://schemas.an

我已经尝试了我能想到的一切,但无法让这个布局工作。它是一个列表视图,列表在一行中匹配

第一行是第一个匹配,下一行是第二个匹配,依此类推。我不介意绿色的笔划和边框

有可能吗


请参见此处的设计:

您需要一个填充ListView的自定义适配器(最好使用RecyclerView&一个带有ViehHolder的适配器),此行布局取自我自己的项目,并不完全符合您的要求,但您会明白的。请发表评论以获取更多信息

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
>

    <TextView
        android:id="@+id/textV_player1"
        android:text="player1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="40dp"
        android:layout_marginEnd="40dp"
        android:textSize="20sp"
        android:paddingTop="15dp"
        android:gravity="end"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/textV_vs"
        android:layout_toStartOf="@+id/textV_vs" />

    <TextView
        android:id="@+id/textV_player2"
        android:text="player2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:paddingTop="15dp"
        android:layout_alignBottom="@+id/textV_vs"
        android:layout_toRightOf="@+id/textV_vs"
        android:layout_toEndOf="@+id/textV_vs" />


    <TextView
        android:id="@+id/textV_vs"
        android:text="vs"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="40dp"
        android:layout_marginEnd="40dp"
        android:textSize="20sp"
        android:layout_above="@+id/textV_points1"
        android:layout_centerHorizontal="true" />


    <TextView
        android:id="@+id/textV_points1"
        android:text="1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:paddingTop="3dp"
        android:paddingBottom="15dp"
        android:layout_below="@+id/textV_player1"
        android:layout_alignRight="@+id/textV_player1"
        android:layout_alignEnd="@+id/textV_player1" />

    <TextView
        android:id="@+id/textV_points2"
        android:text="2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:paddingTop="3dp"
        android:paddingBottom="15dp"
        android:layout_below="@+id/textV_player2"
        android:layout_alignLeft="@+id/textV_player2"
        android:layout_alignStart="@+id/textV_player2" />

    <TextView
        android:id="@+id/textV_vspoints"
        android:text=":"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"    
        android:textSize="20sp"
        android:paddingBottom="15dp"
        android:layout_below="@id/textV_vs"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

您需要一个填充ListView的自定义适配器(最好使用RecyclerView&一个带有ViehHolder的适配器),此行布局取自我自己的项目,并不完全符合您的要求,但您会明白的。请发表评论以获取更多信息

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
>

    <TextView
        android:id="@+id/textV_player1"
        android:text="player1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="40dp"
        android:layout_marginEnd="40dp"
        android:textSize="20sp"
        android:paddingTop="15dp"
        android:gravity="end"
        android:layout_alignParentTop="true"
        android:layout_toLeftOf="@+id/textV_vs"
        android:layout_toStartOf="@+id/textV_vs" />

    <TextView
        android:id="@+id/textV_player2"
        android:text="player2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:paddingTop="15dp"
        android:layout_alignBottom="@+id/textV_vs"
        android:layout_toRightOf="@+id/textV_vs"
        android:layout_toEndOf="@+id/textV_vs" />


    <TextView
        android:id="@+id/textV_vs"
        android:text="vs"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="40dp"
        android:layout_marginEnd="40dp"
        android:textSize="20sp"
        android:layout_above="@+id/textV_points1"
        android:layout_centerHorizontal="true" />


    <TextView
        android:id="@+id/textV_points1"
        android:text="1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:paddingTop="3dp"
        android:paddingBottom="15dp"
        android:layout_below="@+id/textV_player1"
        android:layout_alignRight="@+id/textV_player1"
        android:layout_alignEnd="@+id/textV_player1" />

    <TextView
        android:id="@+id/textV_points2"
        android:text="2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="20sp"
        android:paddingTop="3dp"
        android:paddingBottom="15dp"
        android:layout_below="@+id/textV_player2"
        android:layout_alignLeft="@+id/textV_player2"
        android:layout_alignStart="@+id/textV_player2" />

    <TextView
        android:id="@+id/textV_vspoints"
        android:text=":"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"    
        android:textSize="20sp"
        android:paddingBottom="15dp"
        android:layout_below="@id/textV_vs"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

这里是一个示例实现,但它确实使用了负边距来重叠我称之为badge的内容



要替换背景,只需在适配器中的
getView
中设置背景。

这里是一个示例实现,但它确实使用负边距来重叠我称之为badge的内容



要替换背景,只需在适配器中的
getView
中设置背景。

您缺少图像。嗯,我将其添加为链接,是否有效?:)我认为这应该是一个可以实现的目标。除了文字徽章之外,应该很容易把所有东西都放在适当的位置。对于文本标记,您可能必须定义某些组件的高度,以便通过巧妙使用框架布局或相对布局将其放置在正确的位置。所以右边的结果稍微复杂一点。我建议创建一个包含4个文本值和两个整数的对象。然后,您可以制作一个适配器来列出所有这些缺少图像的对象(我会使用适配器的数据绑定)我认为这应该是一个可以实现的目标。除了文字徽章之外,应该很容易把所有东西都放在适当的位置。对于文本标记,您可能必须定义某些组件的高度,以便通过巧妙使用框架布局或相对布局将其放置在正确的位置。所以右边的结果稍微复杂一点。我建议创建一个包含4个文本值和两个整数的对象。然后,您可以制作一个适配器来列出所有这些对象(我会使用适配器的数据绑定),这看起来很棒。。但是我看不出能不能把数字放在它旁边而不是下面。。这是因为不可能创建一个两边各占40%的视图,中间的字段只占20%的数字和vs吗?只需添加属性
android:layout\u alignLeft=“@+id/textV\u vs”
左边的数字textview,右边的属性相同。若要对此有所了解,请尝试在
design
选项卡中使用,然后拖放视图。这看起来很棒。。但是我看不出能不能把数字放在它旁边而不是下面。。这是因为不可能创建一个两边各占40%的视图,中间的字段只占20%的数字和vs吗?只需添加属性
android:layout\u alignLeft=“@+id/textV\u vs”
左边的数字textview,右边的属性相同。要对此有所了解,请尝试在
design
选项卡中使用,并拖放您的视图。非常感谢!!它像老板一样工作!!现在我只需要让它列出所有数据…:)非常感谢!!它像老板一样工作!!现在我只需要让它列出所有数据…:)