Android ScrollView不尊重孩子的底部保证金

rpe*_*yng 9 android android-layout android-scrollview

我有一个android layout_file,看起来像下面这样

<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
Run Code Online (Sandbox Code Playgroud)

@dimen/activity_margin 是16dp

当我运行应用程序时,我无法滚动到整个布局的底部,因为它不会显示底部边距.这张照片澄清了

在此输入图像描述

请注意,已达到布局底部的提示(从底部发出的光线),但右侧的滚动条表示还有更多内容可向下滚动.

我期望发生的是能够看到底部的边距,就像布局侧面的边距一样.

Vip*_*mar 6

尝试设置

android:fillViewport="true"
Run Code Online (Sandbox Code Playgroud)

在你的滚动视图中。它会给它全高度,然后你可以应用底部边距。


inv*_*dex 6

我遇到了同样的问题。为了解决,我使用了padding而不是margin然后我设置android:fillViewport="true"了 ScrollView。现在一切顺利!