Hello,
I have a ListView that has items added to it at runtime. It is nested
within a LinearLayout, which is inside a ScrollView. Right now, it
only shows the first item on the list. I am trying to figure out how
to adjust the ListView height to change dynamically to always display
all the items within the ListView. I saw a post saying I should not
use wrap_content for the height, but match/fill_parent didn't seem to
help. I also tried calling requestLayout on all the views and that
didn't fix it either.
Any help is greatly appreciated!
For reference, here is my screen layout and ListView item layout:
Screen Layout:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/
android"
android:id="@+id/MainScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="@+id/MainLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!--Other views here-->
<ListView
android:id="@+id/MyListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<EditText
android:id="@+id/MyEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="Item to add" />
<Button
android:id="@+id/MyAddButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Add"
/>
<!--Other views here-->
</LinearLayout>
</ScrollView>
Item Layout (I use a TableLayout to display a border):
<LinearLayout
android:id="@+id/UserLayout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableLayout android:id="@+id/ItemTableLayout"
android:background="#000000" android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow android:background="#555555"
android:layout_margin="2dip" android:padding="20dp">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:text="" android:id="@+id/
Location_TextView" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" android:textSize="8pt"
android:layout_marginLeft="10px"></TextView>
</LinearLayout>
</TableRow>
</TableLayout>
</LinearLayout>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en