I have a FrameLayout and a Listview inside the FrameLayout. I populate the Listview with another Layout. The problem is if I set the layout_height to wrap_content my getview is getting called multiple time for a single record and if I set the layout_height to fill_parent or wrap_content my getview is being called 3 times for a single record. If I set the layout_height to some dp value it is working fine. I mean I dont have any issues with performance and my getview is getting called only once for a record. So I get the screen height and width programmatically using
Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
But if I set the width and height of my Listview with the value measured using the above code the last record of my Listview is partially not visible. I guess this should be because the obtained screen height includes the title bar height, status bar height and notification bar height.
So if that is the prob can someone help me with calculating the available screen height? That is screen height-titlebar height-statusbar height-notification bar height? else What is the problem? why my last record in my ListView is not fully visible?
XML File
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listview"
android:background="#ffffff"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<ListView android:id="@+id/android:list"
android:background="#ffffff"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:clickable="true"
android:fastScrollEnabled="true"
android:smoothScrollbar="true"
/>
</FrameLayout>
Then I set the layout_height and layout_width of the list view in my java code as
Display display = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
FrameLayout.LayoutParams parameters = new FrameLayout.LayoutParams((int)(width),(int)(height));
ListView listview=(ListView) getListView();
listview.setLayoutParams(parameters );