I have problems to fit my ListView in a Popup Dialog when the ListView contains more than 12 ListItems. Is there any attribute I'm missing here or do I have to calculate the max size by myself in code behind?
My Layout looks like this when everything fit perfectly:
And when I have too many Items, as you can see my LinearLayout below the listview and Button disappear.
Here is my Layout.xml
<?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/backgroundgradient" android:orientation="vertical">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="3dp" android:background="@drawable/border" android:orientation="vertical">
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp" android:orientation="horizontal">
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="Caption" android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="3dp" android:background="@drawable/border" android:orientation="vertical">
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp">
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="Caption" android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<ListView android:layout_width="match_parent" android:layout_height="match_parent" android:divider="@android:color/transparent" android:dividerHeight="3dp" android:paddingTop="3dp" android:paddingStart="3dp" android:paddingEnd="1dp" android:choiceMode="singleChoice" android:listSelector="@drawable/selector_list_item"></ListView>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="vertical">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="3dp" android:background="@drawable/border" android:orientation="vertical">
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="10dp">
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Caption" android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content">
<TextView style="@style/dialog_label" android:text="test" />
<TextView style="@style/dialog_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="vertical">
<Button android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:layout_weight="1" android:paddingLeft="2dp" android:paddingRight="2dp" android:text="OK" android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>