问题描述
我一直在尝试使用
但不适用于 scrollview .请注意,我没有使用列表视图,但它是一个带有图像和按钮的大布局.即使用户正在滚动,页脚也应始终位于底部.FourSquare 在他们的应用中有这个,即使在滚动时也有固定的页脚.
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>
推荐答案
似乎您试图使用您拥有的代码将页脚放在滚动视图中.如果您不希望页脚随滚动内容一起移动,则需要将其与滚动视图保持在同一层.将我认为您希望实现的目标放在一起的简单示例.(在这个例子中没有使用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>
这篇关于如何在android中使用scrollview固定页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!