Question

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.

Was it helpful?

Solution

Try setting

android:fillViewport="true"

in your ScrollView. It will give it full height and then you can apply bottom margin.

OTHER TIPS

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!

add android:clipToPadding="false" and android:paddingBottom="32dp" to LinearLayout:

<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:background="@drawable/google_now_style_card"
        android:orientation="vertical"
        android:paddingBottom="32dp"
        android:clipToPadding="false">

    ...

    </LinearLayout
</ScrollView

this worked for ConstraintLayout.

also add android:fillViewport="true" to fill whole of height.

It will work for child of child of scrollview. if you put one child under scrollview it wont consider bottom margin of child. but if you put child under child as shown in code it works fine.

    <ScrollView>
        <LinearLayout>
            <LinearLayout>
                ...
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top