Android ScrollView not respecting child's bottom margin

rperryng picture rperryng · Apr 5, 2014 · Viewed 7.8k times · Source

I have an android layout_file that looks something like the following

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/post_ride_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/activity_margin"
        android:padding="@dimen/activity_margin"
        android:background="@drawable/google_now_style_card"
        android:orientation="vertical" >

    ...

    </LinearLayout
</ScrollView

@dimen/activity_margin is 16dp

When I'm running the app, I am unable to scroll to the bottom of the entire layout, as in, it won't display the bottom margin. This picture clarifies

enter image description here

Note that the hint that the bottom of the layout has been reached (the glow from the bottom), yet the scrollbar on the right indicates that there is more to scroll down to.

What I expect to happen is to be able to see the margin at the bottom, just like the margins at the side of the layout.

Answer

inverted_index picture inverted_index · Jul 16, 2017

I ran into the same problem. To solve, I used padding instead of margin and then I set android:fillViewport="true" for ScrollView. Anything goes well now!