我从 Fedor的ListView实现. 。这是我的ListView项目的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:src="@drawable/stub" android:scaleType="centerCrop"/>
<TextView
      android:id="@+id/name"
      android:layout_width="0px"
      android:layout_height="0px"
      android:layout_weight="0" android:textSize="20dip" android:layout_marginLeft="10dip"/>
<TextView
      android:id="@+id/address"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1"  android:textSize="16dip" android:layout_marginLeft="10dip"/>

</LinearLayout>

我在设备上看到的是ImageView,并且从左到右顺序显示的两个文本视图。

我想要的是右侧的图像视图(这已经是正确的),imageView右侧的名称文本视图(这是正确的)和“ textView”下方的地址文本视图。我无法弄清楚如何正确布置这个。

请注意,我知道我可以在名称中添加一条新行,并在此之后包含地址文本,但是我希望这两个元素具有不同的字体尺寸,因此这不是一个选择。非常感谢!

有帮助吗?

解决方案

您需要设置线安装的方向并实现您想做的事情,您需要使用其中的几个。在伪代码中,您必须做:

<LinearLayout
    android:orientation="horizontal"
    ...>
    <ImageView
        android:id="@+id/image"
        ... />
    <LinearLayout
        android:orientation="vertical"
        ...>
        <TextView
             android:id="@+id/name"
             ...>

        <TextView
             android:id="@+id/address"
             ...>
    </LinearLayout>
</LinearLayout>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top