View in ScrollView isn't matching parent as configured

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 .


Try adding android:fillViewport="true"to your ScrollView

remember that android:layout_height=”fill_parent” means “set the height to the height of the parent.” This is obviously not what you want when using a ScrollView. After all, the ScrollView would become useless if its content was always as tall as itself. To work around this, you need to use the ScrollView attribute called android:fillViewport. When set to true, this attribute causes the scroll view’s child to expand to the height of the ScrollView if needed. When the child is taller than the ScrollView, the attribute has no effect.