基于Android的列表视图设计

基于Android的列表视图设计,android,android-listview,Android,Android Listview,这是我的XML,用于在列表视图上显示用户信息,因此当前它包含两个文本视图,我在其中显示用户信息 问题陈述:- 每当我运行我的应用程序时,我总是看到我的文本视图并排出现。例如,我总是得到下面这样的东西- SomeImage TextView1 TextView2 这是我不想要的。我需要这样的东西——假设将来我有三个TextView SomeImage TextView1 Text

这是我的XML,用于在
列表视图上显示
用户信息
,因此当前它包含两个
文本视图
,我在其中显示用户信息

问题陈述:-

每当我运行我的应用程序时,我总是看到我的
文本视图
并排出现。例如,我总是得到下面这样的东西-

SomeImage             TextView1             TextView2
这是我不想要的。我需要这样的东西——假设将来我有三个TextView

SomeImage             TextView1

                      TextView2

                      TextView3
下面是我目前正在使用的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_height="wrap_content" >

    <ImageView
        android:id="@+id/image"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:scaleType="centerCrop"
        android:src="@drawable/stub" />

    <TextView
        android:id="@+id/text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left|center_vertical"
        android:layout_marginLeft="10dip"
        android:layout_weight="1"
        android:textSize="10dip" />

    <TextView
        android:id="@+id/text1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left|center_vertical"
        android:layout_marginLeft="10dip"
        android:layout_weight="1"
        android:textSize="10dip" />

</LinearLayout>

试试这个:

<?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="wrap_content"
    android:padding="10dp" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="50dip"
    android:layout_height="50dip"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginRight="10dp"
    android:src="@drawable/stub" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/imageView1"
    android:layout_toRightOf="@+id/imageView1"
    android:text="TextView1" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_toRightOf="@+id/imageView1"
    android:text="TextView2" />


<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView2"
    android:layout_toRightOf="@+id/imageView1"
    android:text="TextView3" />

</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="wrap_content"
    android:padding="10dp" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="50dip"
    android:layout_height="50dip"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginRight="10dp"
    android:src="@drawable/stub" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/imageView1"
    android:layout_toRightOf="@+id/imageView1"
    android:text="TextView1" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView1"
    android:layout_toRightOf="@+id/imageView1"
    android:text="TextView2" />


<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView2"
    android:layout_toRightOf="@+id/imageView1"
    android:text="TextView3" />

</RelativeLayout>

线性布局
的方向为。只需将这一行添加到您的


线性布局
的方向为。只需将这一行添加到您的


考虑更改为<代码> RealValayOuts<代码>,而不是<代码>线性布局。您将获得成功。请考虑更改为<代码> RealValayOut< <代码>,而不是<代码>线性布局< /代码>,您将获得成功。