Android 使listview RelativeLayout在每个项目上对齐

Android 使listview RelativeLayout在每个项目上对齐,android,android-listview,Android,Android Listview,我在android上使用lsitview relativelayout时遇到问题,结果与我想要的不匹配 结果是这样的 麦可德 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_heig

我在android上使用lsitview relativelayout时遇到问题,结果与我想要的不匹配

结果是这样的

麦可德

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView3"
        android:layout_below="@+id/textView3"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView4"
        android:layout_below="@+id/textView4"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="25dp"
        android:layout_toRightOf="@+id/textView1"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="25dp"
        android:layout_toRightOf="@+id/textView2"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView7"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView6"
        android:layout_below="@+id/textView6"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="25dp"
        android:layout_toRightOf="@+id/textView3"
        android:text="Large Text"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</RelativeLayout>

您正在尝试使用TextView模拟ListView吗?如果这是正确的,您需要为每个TextView创建或设置一个“样式”,并将其添加为:

android:layout_marginX="<NUMBER>"
android:layout_marginX=“”
其中X是左、右、上、下或仅边距,用于设置四个边距。 还可以尝试使用RelativeLayout的属性,如
android:layout\u alignLeft=“

尝试使用此页面查找RelativeLayout属性

如果您将“android:id=“@+id/textView2”设置为可见,则这将有助于您实现这种对齐方式。将visiblility设置为“不可见”,然后您将获得正确的对齐…

您可以将textview(其背景为黑色或黑色条)的宽度设置为最大可能值,如果没有要显示的文本,则可以将textview可见性设置为“不可见”

你想把每一项都对齐吗?是的,这就是我的意思,对不起我的错误english@student080705639:在上述代码中,您在哪里使用listview?您已经安排了一组文本视图,希望它们显示为文本视图?您需要固定所有文本视图的宽度。此外,您还需要在xml中设置listview布局\u width=match\u父级。能否显示您真正想要的图像?它是listview吗?谢谢,我在layout\u marginLeft中手动添加,并且所有内容都对齐
android:layout_marginX="<NUMBER>"