Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ScrollView not respecting child's bottom margin

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.

like image 979
rperryng Avatar asked Apr 05 '14 17:04

rperryng


2 Answers

Try setting

android:fillViewport="true"

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

like image 57
VipulKumar Avatar answered Sep 23 '22 00:09

VipulKumar


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!

like image 30
inverted_index Avatar answered Sep 25 '22 00:09

inverted_index