On the ScrollView use android:fillViewport="true" and for child of ScrollView android:height="wrap_content". If you would like to have many child’s with different attributes make a main child as container. Set it as wrap_content and its child as match_parent .
example :
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:id="@+id/dynamic_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/dimrix_sub_child"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone" >
</LinearLayout>
<LinearLayout
android:id="@+id/dimrix_sub_child_21"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone" >
</LinearLayout>
</LinearLayout>
</ScrollView>
In this example I can set visibility in the code for each child and it will match parent as you wish .