androidandroid-layoutandroid-scrollview

How to add space below scroll view


I have wrapped an activity in an scroll view like following.

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    >

    <include layout="@layout/content_form" />

</ScrollView>

I have around 15 fields in the content_form layout, the issues is that the last item in content_form layout is attached with bottom.

I need to add a margin below the scroll view, i have tried giving margin to scrollviewand the last item of content_form field, but nothing is working.

I need to know how to add margin at the bottom of page when using scroll view.


Solution

  • If you want the scrolling margin to be within the content, it would be best to add it to content_form. You should be able to accomplish this by either adding paddingBottom to your parent container in that layout, or layout_marginBottom on your last view aligned to the parent bottom.