在Scrollview的底部制作一个RelativeLayout [英] Make a RelativeLayout at the bottom of a Scrollview
问题描述
我在Scrollview中有一个TableLayout,我想在ScrollView => TableLayout的底部设置一个FIXED RelativeLayout.有了该XML代码,我始终在TableLayout上方拥有RelativeLayout:
I have a TableLayout inside a Scrollview, I want to set a FIXED RelativeLayout at the bottom of the ScrollView=>TableLayout. With that XML code, I have always that RelativeLayout above the TableLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:glowpad="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/classement_layout"
android:background="#000000">
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:scrollbarFadeDuration="1000"
android:id="@+id/scroll_table"
android:scrollbarSize="12dip" >
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:shrinkColumns="*"
android:stretchColumns="*"
android:background="#000000" >
</TableLayout>
</ScrollView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_alignBottom="@+id/scroll_table"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="22dp"
android:src="@drawable/green" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView1"
android:text="Qualification pour la ligue des champions"
android:textColor="#ffffff"/>
<ImageView
android:id="@+id/imageView2"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignLeft="@+id/imageView1"
android:layout_centerVertical="true"
android:src="@drawable/blue" />
</RelativeLayout>
</RelativeLayout>
推荐答案
只需将您的表格布局封装在另一个相对布局中,然后将页脚"相对布局放置在表格布局下方,并在页脚上使用layout_below属性将其保持在表格下方布局
Just encase your tablelayout inside of another relativelayout and then place your "footer" relativelayout below the tablelayout and use the layout_below attribute on the footer to keep it under your table layout
<ScrollView>
<RelativeLayout
stuff...>
<TableLayout
stuff.../>
<RelativeLayout
android:layout_below="@+id/TableLayout"
stuff...></RelativeLayout>
</RelativeLayout>
</ScrollView>
为了始终使页脚" RelativeLayout始终位于底部,请像这样放置它:
In order to just have the "footer" RelativeLayout at the bottom at all times just place it like this:
<ScrollView>
<RelativeLayout
stuff...>
<TableLayout
stuff.../>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:layout_below="@+id/ScrollView"
stuff...></RelativeLayout>
这篇关于在Scrollview的底部制作一个RelativeLayout的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!