I have to generate a dynamic listview in android. The listview is put inside a scrollview because I have other content too to display above the listview. Something like this :

Down part is the listview which is dynamically added. This all comes fine on a portrait mode on Samsung note5 but when I change the screen orientation to landscape the listview does not scroll. This could be because I have given wrap-content for the listview.
Please check my layout code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/rootLayout">
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:background="@color/gray25"
        android:id="@+id/scrollView"
        android:layout_above="@id/footer">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:id="@+id/mainLayout"
            android:background="@color/light_blue"
            android:paddingBottom="@dimen/_10sdp">
        <!--Top header-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:gravity="center_vertical"
                android:id="@+id/topheader"
                android:background="@drawable/dashboard_button"
                android:layout_marginLeft="@dimen/_5sdp"
                android:layout_marginRight="@dimen/_5sdp"
                android:layout_marginTop="@dimen/_5sdp"
                android:padding="@dimen/_5sdp">
            </LinearLayout>
        <!--middle portion-->
            <ListView
                android:id="@+id/RFIDList"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:transcriptMode="alwaysScroll"
                android:layout_marginTop="@dimen/_10sdp"
                android:background="@drawable/dashboard_button"
                android:layout_marginLeft="@dimen/_5sdp"
                android:layout_marginRight="@dimen/_5sdp"
                android:minHeight="@dimen/_50sdp" />
        </LinearLayout>
    </ScrollView>
<!-- Footer aligned to bottom -->
    <RelativeLayout
        android:id="@+id/footer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:gravity="center"
        android:background="@color/white">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="left"
            android:layout_centerInParent="true"
            android:layout_marginLeft="@dimen/_15sdp">               
        </LinearLayout>
    </RelativeLayout>
</RelativeLayout>
I cannot give fixed height to the listview because its items are generated dynamically. I tried to find the solution and also tried changing my listview to recyclerview but did not work. but Any help would be appreciated.
 
     
     
    