ScrollView中的RelativeLayout,其按钮与其父级底部对齐

f_f*_*ola 2 android alignment scrollview relativelayout android-layout

我有一个RelativeLayout"标题/正文/页脚"风格的结构.

  • 在标题部分,我有一个TextView显示当前片段的标题;

  • 所述主体包括一个ScrollView包装一元件RelativeLayout,其包含其他元素;

  • 最后,页脚只有一个Button.

具体来说,结构如下:

<RelativeLayout>
    <TextView />                <!-- the header -->

    <ScrollView>                <!-- the body -->
        <RelativeLayout>
            <!-- other elements -->
        </RelativeLayout>
    </ScollView>

    <Button />                  <!-- the footer -->

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

现在,我希望按钮始终位于main的底部RelativeLayout,因此我分配了属性android:layout_alignParentBottom="true".

此外,ScrollView必须填写所有正文,因此属性android:fillViewport="true"已设置.

问题:事实是页脚中的按钮超过了最后一部分ScrollView,从而隐藏了RelativeLayout包含主体的最终元素.有没有解决方案可以解决这个问题?

and*_*rei 5

尝试设置

android:layout_above="@+id/id_of_your_button"
Run Code Online (Sandbox Code Playgroud)

在ScrollView上