我有一个 ListView,每行都有一张照片,在照片下方有另一个 ListView,上面有关于照片的评论。问题是子 ListView 只显示第一行,因为父 ListView 的大小。
有什么方法可以根据子 ListView 大小使父 ListView 大小灵活吗?
我的xml代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relLayoutMain"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@layout/background" 
    >
    <ListView
        android:id="@+id/photoList"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:cacheColorHint="#00000000"
        android:footerDividersEnabled="true"
        android:paddingTop="5sp" >
    </ListView>     
</RelativeLayout>
photoList 的行布局为:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content" >
    <ImageView
       android:id="@+id/imgView"
       android:contentDescription="@string/app_name"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:paddingLeft="10dp"
       android:paddingRight="10dp"
       android:layout_below="@+id/llUserHeader"
       android:adjustViewBounds="true"
       />
    <ListView android:id="@+id/commentList"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:layout_below="@+id/imgView"   
        android:cacheColorHint="#00000000"
        android:footerDividersEnabled="true"
        >
    </ListView>
</RelativeLayout>
commentList 的行布局是:
<?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:paddingLeft="10sp"
   android:paddingRight="10sp"
   android:paddingTop="5sp"
   android:orientation="horizontal"
   >
    <TextView
            android:id="@+id/usernamecomment"
            android:text="@string/share_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="15sp"
             />
    <TextView 
        android:id="@+id/comment"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_marginLeft="3sp"
        />
</LinearLayout>