按钮栏不会粘在屏幕的底部

Han*_*ore 7 xml android

我正在尝试将我创建的按钮栏放在每个屏幕的底部.我成功完成了第一个屏幕相当容易.

现在我试着把它放在其他屏幕上,但似乎它不能粘在屏幕的底部.当我查看hiearchyviewer时,看起来像包裹着我的布局和按钮栏的RelativeLayout,虽然没有填满整个屏幕,但它的高度设置为填充父级.

任何人都可以通过指出我哪里出错来帮助我吗?

这是我使用的XML:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:orientation="vertical">
    <TableLayout android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:padding="5pt" android:id="@+id/table"
        android:stretchColumns="1">
        <TableRow>
            <TextView android:text="@string/Arbeiderbediende"
                android:id="@+id/txtArbeiderBediende" android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
        </TableRow>

        <TableRow android:gravity="center">
            <RadioGroup android:layout_width="fill_parent"
                android:layout_height="wrap_content" android:orientation="horizontal"
                android:id="@+id/group1">

                <RadioButton style="@style/RadioButton"
                    android:layout_width="wrap_content" android:id="@+id/rbArbeider"
                    android:text="@string/Arbeider" android:layout_height="wrap_content"
                    android:paddingLeft="18pt" />

                <RadioButton style="@style/RadioButton"
                    android:layout_width="wrap_content" android:id="@+id/rbBediende"
                    android:text="@string/Bediende" android:layout_height="wrap_content"
                    android:layout_marginLeft="20pt" android:paddingLeft="18pt" />
            </RadioGroup>
        </TableRow>

        <TableRow android:gravity="center" android:paddingTop="5dip">
            <TextView android:text="@string/OverzichtFuncties"
                android:id="@+id/txtFuncties" android:layout_width="0dip"
                android:layout_weight="1" android:layout_height="wrap_content" />

            <Spinner android:layout_height="wrap_content" style="Spinner"
                android:layout_width="0dip" android:layout_weight="2"
                android:id="@+id/cmbFuncties" />
        </TableRow>

        <TableRow android:gravity="center" android:paddingTop="5dip">
            <TextView android:text="@string/Regio" android:id="@+id/txtRegio"
                android:layout_width="0dip" android:layout_weight="1"
                android:layout_height="wrap_content" />

            <Spinner android:layout_height="wrap_content"
                android:layout_width="0dip" android:layout_weight="2" android:id="@+id/cmbRegio" />
        </TableRow>

        <TableRow android:gravity="center" android:paddingTop="5dip">
            <TextView android:text="@string/Opleiding" android:id="@+id/txtOpleidingsniveau"
                android:layout_width="0dip" android:layout_weight="1"
                android:layout_height="wrap_content" />

            <Spinner android:layout_height="wrap_content"
                android:layout_width="0dip" android:layout_weight="2"
                android:id="@+id/cmbOpleidingsniveau" />
        </TableRow>

        <Button android:text="@string/VindJobButton" android:id="@+id/btnFindJob"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:layout_marginTop="10dip" />


    </TableLayout>

    <stage.accent.Toolbar android:layout_width="fill_parent"
        android:layout_height="70dip" android:layout_alignParentBottom="true"
        android:layout_below="@+id/table" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这是我实现的结果和我想要的结果

在此输入图像描述 在此输入图像描述

rek*_*eru 6

如果你希望你的按钮栏在屏幕的底部总是可见的,而不是与内容滚动,你可能要切换你RelativeLayoutScrollView标签,并移动按钮栏是你的第一个孩子RelativeLayout时,ScrollView是第二个:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
    <stage.accent.Toolbar android:id="id/buttonBar" android:layout_width="fill_parent"
        android:layout_height="70dip" android:layout_alignParentBottom="true" />
    <ScrollView android:layout_above="@+id/buttonBar"
        android:layout_width="fill_parent" android:layout_height="fill_parent">
        <TableLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:padding="5pt" android:id="@+id/table"
            android:stretchColumns="1">
            <TableRow>
                <TextView android:text="@string/Arbeiderbediende"
                    android:id="@+id/txtArbeiderBediende" android:layout_width="wrap_content"
                    android:layout_height="wrap_content" />
            </TableRow>
            <TableRow android:gravity="center">
                <RadioGroup android:layout_width="fill_parent"
                    android:layout_height="wrap_content" android:orientation="horizontal"
                    android:id="@+id/group1">

                    <RadioButton style="@style/RadioButton"
                        android:layout_width="wrap_content" android:id="@+id/rbArbeider"
                        android:text="@string/Arbeider" android:layout_height="wrap_content"
                        android:paddingLeft="18pt" />

                    <RadioButton style="@style/RadioButton"
                        android:layout_width="wrap_content" android:id="@+id/rbBediende"
                        android:text="@string/Bediende" android:layout_height="wrap_content"
                        android:layout_marginLeft="20pt" android:paddingLeft="18pt" />
                </RadioGroup>
            </TableRow>
            <TableRow android:gravity="center" android:paddingTop="5dip">
                <TextView android:text="@string/OverzichtFuncties"
                    android:id="@+id/txtFuncties" android:layout_width="0dip"
                    android:layout_weight="1" android:layout_height="wrap_content" />

                <Spinner android:layout_height="wrap_content" style="Spinner"
                    android:layout_width="0dip" android:layout_weight="2"
                    android:id="@+id/cmbFuncties" />
            </TableRow>
            <TableRow android:gravity="center" android:paddingTop="5dip">
                <TextView android:text="@string/Regio" android:id="@+id/txtRegio"
                    android:layout_width="0dip" android:layout_weight="1"
                    android:layout_height="wrap_content" />

                <Spinner android:layout_height="wrap_content"
                    android:layout_width="0dip" android:layout_weight="2" android:id="@+id/cmbRegio" />
            </TableRow>
            <TableRow android:gravity="center" android:paddingTop="5dip">
                <TextView android:text="@string/Opleiding" android:id="@+id/txtOpleidingsniveau"
                    android:layout_width="0dip" android:layout_weight="1"
                    android:layout_height="wrap_content" />

                <Spinner android:layout_height="wrap_content"
                    android:layout_width="0dip" android:layout_weight="2"
                    android:id="@+id/cmbOpleidingsniveau" />
            </TableRow>
            <Button android:text="@string/VindJobButton" android:id="@+id/btnFindJob"
                android:layout_width="fill_parent" android:layout_height="wrap_content"
                android:layout_marginTop="10dip" />
        </TableLayout>
    </ScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

这样你就能达到你想要的效果:

肖像景观

按钮栏将始终位于屏幕底部.

通过滚动内容,您将能够看到它的最后一点,它不会隐藏在按钮栏后面:

景观2