Buttonbar 不会粘在屏幕底部 [英] Buttonbar won't stick to bottom of screen

查看:23
本文介绍了Buttonbar 不会粘在屏幕底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to put the buttonbar I've created on the bottom of each screen. I've succeeded for the first screen fairly easy.

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

Now I've tried to put it other screens, but it seems that it can't stick to the bottom of the screen. When I look in the hiearchyviewer, it looks like the RelativeLayout that's wrapped araound my layout and buttonbar, isn't filling the whole screen, though, its height is set to fill parent.

谁能帮我指出我哪里出错了?

Can anyone help me by pointing out where I'm going wrong?

这是我使用的 XML:

This is the XML I use:

<?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>

这是我取得的结果,也是我想要的结果

This is the result I achieved and the result I want to get

推荐答案

如果您希望按钮栏始终在屏幕底部可见并且不随内容滚动,您可能需要切换 RelativeLayoutScrollView 标签,并将你的按钮栏移动到你的 RelativeLayout 的第一个子元素,ScrollView 成为第二个:

In case you want your buttonbar to be always visible at the bottom of the screen and not scroll with the content, you might want to switch your RelativeLayout and ScrollView tags, and move your buttonbar to be the first child of your RelativeLayout, the ScrollView to be the second:

<?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>

这样你就可以实现你想要的:

This way you'll be able to achieve what you want:

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

The button bar will be always at the bottom of your screen.

并且通过滚动内容,您也可以看到它的最后一点,它不会隐藏在按钮栏后面:

And by scrolling the content, you'll be able to see the last bit of it too, it won't be hidden behind the buttonbar:

这篇关于Buttonbar 不会粘在屏幕底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆