如何添加页脚到全屏滚动型

如何添加页脚到全屏滚动型

本文介绍了Android的:如何添加页脚到全屏滚动型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想页脚在屏幕的底部锚定当且仅当它可以被锚定在那里不重叠任何其它视图。

I want the footer to be anchored at the bottom of the screen if and only if it can be anchored there without overlapping any other views.

的问题是,不知道有多少次将要加入到页眉或页脚

The problem is that I don't know how many views are going to be added to the header or the footer.

如果把页脚在窗口的底部将使其重叠,我想把页脚在滚动视图的底部。 (也许将它添加到与它需要的顶级组件下面的规则RelativeLayout的?)

If putting the footer at the bottom of the window would make it overlap, I want to put the footer at the bottom of the scrollview. (Maybe by adding it to the RelativeLayout with the rule that it needs to be below the top component?)

下面是我想要得到一个PIC:

Here is a pic of what I'm trying to get:

期望的结果

其中:

1)RelativeLayout的既包含TableLayout在顶部,和的LinearLayout在底部

1)The RelativeLayout contains both the TableLayout at the top, and the LinearLayout at the bottom.

2)TableLayout向下扩展为TableRows被添加到它。

2)The TableLayout expands downwards as TableRows get added to it.

3)的LinearLayout的视图可以被添加到它的底部扩展了。

3)The LinearLayout expands up from the bottom as views get added to it.

~~~

我想为滚动视图,以增长的大小只够容纳的组件不重叠。

I'd like for the scrollview to grow in size only enough to fit the components without overlapping.

在此先感谢这样真棒社区支持

Thanks in advance for such awesome community support

推荐答案

我想你可以解决它的线性布局。您可以设置三个街区的线性布局:头,身,尾。将身体FILL_PARENT和layout_weight = 1,这样身体会扩大到什么填补后留下的页眉和页脚采取了它的部分来自父母。整体结构的地方进入滚动型。

I think you can solve it in linear layout. You set three blocks in linear layout: header, body, footer. Set body to fill_parent and layout_weight=1, this way body will expand to fill what left after header and footer taken its part from parent. Whole structure place into ScrollView.

<?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"
    android:fillViewport="true">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TableLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TableRow><TextView android:text="Text1"/></TableRow>
            <TableRow><TextView android:text="Text2"/></TableRow>
        </TableLayout>
        <RelativeLayout
            android:layout_weight="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <TextView
                android:text="@string/lorem_ipsum"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        </RelativeLayout>
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="Text3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
            <TextView
                android:text="Text4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        </LinearLayout>
    </LinearLayout>
</ScrollView>

在我的Andr​​oid 2.1模拟器测试此,它看起来它的工作原理。

I tested this in Emulator of Android 2.1 and it looks it works.

这篇关于Android的:如何添加页脚到全屏滚动型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 19:47