Reputation: 21
I have an android app with a mainactivity that contain a listview, this is the code of the main activity layout:
<?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="fill_parent"
android:orientation="vertical" >
<ListView android:id="@+id/commandList"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
</LinearLayout>
in the listview I display a partial view, this is the code of view layout:
<?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:orientation="vertical" >
<TextView
android:id="@+id/commandText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
I wish that the elements would fill the height of mainactivitylayout but the result is this: result image
thank you regards
Upvotes: 2
Views: 4028
Reputation: 6728
Waqas
is right in above comment. (It totally kills the purpose of using ListView)
But still you want to implement this then in getView() of adapter try below code
convertView.getLayoutParams().height = parent.getHeight() / NO_OF_ITEMS;
convertView.requestLayout();
Upvotes: 6