如何有一个固定的页脚滚动型的机器人?机器人、有一个

2023-09-05 05:01:43 作者:爱情的独奏

我一直在尝试使用

Fixed页脚不显示最下面的列表项

,但不与滚动视图工作。 注意:我不使用列表视图,但它是一个大的布局与图像和按钮。 页脚应被定位在钮总是甚至当用户滚动。 四角有这个在他们的应用程序,其中有固定的页脚即使滚动。

but does not work with scrollview . Note i am not using listview but it is a big layouts with images and buttons . The footer should be positioned at the botton always even while user is scrolling . FourSquare has this in their app where there is fixed footer even while scrolling.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >

<RelativeLayout
    android:id="@+id/root"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:id="@+id/search_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@color/red" />

    <LinearLayout
        android:id="@+id/main_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/search_container"
        android:layout_below="@+id/root"
        android:background="@color/layout_bg_wallet_login"
        android:orientation="vertical" >
        ------More Buttons and Images
    </LinearLayout>
</RelativeLayout>

推荐答案

好像你试图把页脚与code你有滚动视图中。如果你不想页脚移动与您的滚动内容,你需要保持它的同一层的滚动视图。放在一起的东西,我相信你希望实现的一个简单的例子。 (未使用的strings.xml或colors.xml在这个例子中,但他们应该被用在一个真正的项目)

Seems like your trying to put the footer inside the scroll view with the code you have. If you don't want the footer to move with your scroll content, you need to keep it on the same layer as the scroll view. Put together a simple example of what I believe your looking to accomplish. (didn't use strings.xml or colors.xml in this example but they should be used in for a real project)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@+id/footer"
    android:background="#0000ff"
    android:fillViewport="true" >

    <TextView
        android:id="@+id/texthere"
        android:layout_width="160dp"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:gravity="center_vertical|center_horizontal"
        android:text="test test test test test test test test test test 
        test test test test test test test test test test test test test 
        test test test test test test test test test test test test test"
        android:textSize="35sp" >
    </TextView>
</ScrollView>

<RelativeLayout
    android:id="@+id/footer"
    android:layout_width="fill_parent"
    android:layout_height="100dp"
    android:background="#ffff00" 
    android:layout_alignParentBottom="true">

    <TextView
        android:id="@+id/texthere2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="things in your footer here"
        android:textSize="20sp" />

</RelativeLayout>

</RelativeLayout>