有人实现ExpandableListView里面布局吗?我试图做到这一点,我有高度问题。我想使它成为“wrap_content”,以便在展开时查看完整展开的View。但不幸的是,对于“wrap_content”参数,我无法实现此结果。有人可以帮忙吗?Android listview里面的相对布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/user"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_below="@+id/rl"
android:layout_toRightOf="@+id/user"
android:paddingLeft="3dp"
android:text="Top User"
android:textColor="#000000"
android:textSize="22dp" />
<ExpandableListView
android:id="@+id/elvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/user"
android:layout_above="@+id/about" >
</ExpandableListView>
<TextView
android:id="@+id/about"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:text="Bottom About"
android:textColor="#6f6f6f"
android:textSize="24dp"
android:textStyle="bold" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
组一行ExpandableListView:
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@+id/groupname"
xmlns:android="http://schemas.android.com/apk/res/android"
android:textStyle="bold"
android:textSize="20dp"
android:paddingLeft="40dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="@drawable/expanded_upper_selector"
android:gravity="center_vertical"/>
子行
<?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:background="@drawable/ingredients_selector">
<TextView android:id="@+id/ingredients_second_layer_text"
android:textStyle="bold"
android:textSize="20dp"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:textColor="@color/dark_orange"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"/>
高度有什么问题? – 2012-07-19 09:06:58
高度“wrap_content”不包装扩展列表视图。展开的列表视图无法完整显示。只能看到它的一小部分。 – Stas 2012-07-19 09:10:51
是的,我只是做了 – Stas 2012-07-19 09:12:13