I am using a Fragment for displaying a calendar widget inside it and another ListView in the same activity. my ListView is shown always and the Fragment which has the calendar is added to the activity on at the bottom button click and I will be removed when user clicks the button again.
Now I am trying to display the ListView in the remaining space on the top whenever the calendar is visible.
I am not able to get the height of the Fragment as it gives me 0 always. If I get that I can subtract it from Screen size and render the ListView with that height. I tried using a constant height for calendar fragment which is not working in all devices as they have different height for different resolutions.
My xml below,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<!-- The main content view -->
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_background_morning" >
<LinearLayout
android:id="@+id/r1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp"
>
<ListView
android:id="@+id/lv1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:divider="@null"
android:background="@color/transparent"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/calendar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true"
>
</LinearLayout>
</RelativeLayout>
<!-- The navigation drawer -->
</LinearLayout>