I'm trying to make a view that contains "two" ListViews. The first one's height should be equal to a single list item height, and the second ListView's height should take up the remaining space.
Any ideas?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:baselineAligned="false"
android:divider="?android:attr/dividerHorizontal"
android:orientation="vertical" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragment_forecast"
android:name=MyFragment"
android:layout_width="fill_parent"
android:layout_height="100dp"
tools:layout="@android:layout/list_content" />
<FrameLayout
android:id="@+id/fragment_wear"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Why people are -1 this!! If you don't know the answer then just simply move to another!
The real question is, what benefit do you hope to achieve by having a ListView that only shows 1 item - why not just display that item in a standard View?
If you have a fixed height ListItem, you can set this as the
android:layout_height
attribute:While I agree that the code snippet in the OP contributes nothing to the question, the question itself is very reasonable and I had to do exactly the same thing in my project.
The way this can be done (assuming all items in the list have the same height) is by measuring an item once and assigning its height to the listview. Here is what worked for me (adapter's code):