如何在滚动视图下方添加空间

dev*_*v90 2 android android-layout android-scrollview

我将活动包装在scroll view下面的类似文件中。

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

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

</ScrollView>
Run Code Online (Sandbox Code Playgroud)

我在content_form布局中大约有15个字段,问题是布局中的最后一项content_form附有底部。

我需要在滚动视图下方添加一个边距,我已经尝试给scrollviewcontent_form字段和最后一个字段赋予边距,但是没有任何作用。

使用时,我需要知道如何在页面底部添加边距scroll view

May*_*m R 13

这会在滚动视图中的最后一个项目下进行填充。可能对你有好处

 <androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:paddingBottom="80dp"
    android:clipToPadding="false"
    android:layout_height="match_parent">
Run Code Online (Sandbox Code Playgroud)


Bry*_*ier 10

如果您希望滚动边距在内容内,最好将其添加到content_form. 您应该能够通过添加paddingBottom到该布局中的父容器或layout_marginBottom在与父底部对齐的最后一个视图上来完成此操作。


Chr*_*eer 5

在这里,您需要给出padding ,而不是 margin

尝试为 ScrollView 提供填充。


小智 5

您可以出于以下目的使用SpaceView

<Space
 android:layout_width="100dp"
 android:layout_height="match_parent"/>
Run Code Online (Sandbox Code Playgroud)

要么,

 <View
  android:layout_width="100dp"
  android:layout_height="match_parent"
  android:layout_weight="1"/>
Run Code Online (Sandbox Code Playgroud)