下面的按钮扩展scrollview

Mat*_*ieu 16 user-interface android android-layout

我试图实现的布局(我认为)非常简单.

一个TextView根据内部的内容进行扩展.下面是两个按钮(确定/取消).

我可以让按钮贴在屏幕的底部,并且工作正常.但我想在TextView下面放置这些按钮.我尝试了很多不同的东西,但这是我最新的布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
        >
    <ScrollView android:id="@+id/Scroll"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
            >
        <TextView
                android:id="@+id/Text"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                />
    </ScrollView>
    <RelativeLayout android:id="@+id/buttons"
                    android:layout_height="fill_parent"
                    android:layout_width="fill_parent"
                    android:layout_below="@+id/Scroll"
                    android:layout_above="@+id/bottom"
            >
        <LinearLayout
                android:orientation="horizontal"
                android:layout_height="wrap_content"
                android:layout_width="fill_parent">
            <Button android:id="@+id/ButtonOK"
                    android:layout_height="80dp"
                    android:layout_width="fill_parent"
                    android:text="OK"
                    android:layout_weight="1"/>
            <Button android:id="@+id/ButtonCancel"
                    android:layout_height="80dp"
                    android:layout_width="fill_parent"
                    android:text="Cancel"
                    android:layout_weight="1"/>
        </LinearLayout>
    </RelativeLayout>
    <LinearLayout android:id="@+id/bottom"
                  android:layout_height="0px"
                  android:layout_width="fill_parent"
                  android:layout_alignParentBottom="true"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

最后的空线性布局是(不成功)尝试阻止视图延伸到屏幕底部...

在我尝试过的所有内容中,按钮都位于屏幕的底部,或者当TextView太大时它们会经过它们.

这是我想要做的草图:在此输入图像描述

Che*_*mon 24

目标是只有一个可滚动区域占据整个页面减去底部某些按钮占用的数量?

如果是这种情况,您可以LinearLayout在外层使用a 并使用权重:

<LinearLayout 
   android:layout_height="wrap_content" 
   orientation="vertical"...>
   <ScrollView
      android:layout_height="0dp"
      android:layout_weight="1"
      .../>
   <LayoutWithButtons
      android:layout_height="wrap_content"
      ..../>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)