ScrollView中的RelativeLayout,其按钮与其父

时间:2015-07-31 14:28:19

标签: android android-layout alignment scrollview relativelayout

我在"标题/正文/页脚"中有一个RelativeLayout结构样式。

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

  • 正文包含ScrollView元素包裹RelativeLayout,其中包含其他元素;

  • 最后,页脚只有一个Button

具体来说,结构如下:

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

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

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

</RelativeLayout>

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

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

问题:事实是,页脚中的按钮会越过ScrollView的最后一部分,从而隐藏包含正文的RelativeLayout的最终元素。有没有解决方案来解决这个问题?

1 个答案:

答案 0 :(得分:5)

尝试设置

android:layout_above="@+id/id_of_your_button"
ScrollView上的