我试图将我创建的按钮栏放在每个屏幕的底部。我很容易就成功地完成了第一个屏幕。
现在我尝试把它放到其他屏幕上,但似乎无法粘在屏幕底部。当我查看 hiearchyviewer 时,看起来包裹在我的布局和按钮栏周围的相对布局并没有填充整个屏幕,但它的高度设置为填充父级。
谁能帮助我指出我哪里出错了?
这是我使用的 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>
这就是我达到的结果,也是我想要得到的结果
如果您希望按钮栏始终在屏幕底部可见并且不随内容滚动,您可能需要切换RelativeLayout
and ScrollView
标签,并将您的按钮栏移动到您的第一个子元素RelativeLayout
, the 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>
这样你就能够实现你想要的:
and ![landscape](https://i.stack.imgur.com/K6fEv.jpg)
按钮栏将始终位于屏幕底部。
通过滚动内容,您也可以看到它的最后一点,它不会隐藏在按钮栏后面:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)