Pre*_*thi 6 android footer scrollview relativelayout android-layout
我一直在尝试使用
但不适用于scrollview.注意我没有使用listview,但它是一个带图像和按钮的大布局.即使在用户滚动时,页脚也应始终位于按钮上.FourSquare在他们的应用程序中有这个,即使在滚动时也有固定的页脚.
<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>
Run Code Online (Sandbox Code Playgroud)
AJa*_*Jak 37
好像你试图用你的代码将页脚放在滚动视图中.如果您不希望页脚随滚动内容移动,则需要将其与滚动视图保持在同一层上.把我认为你想要完成的事情放在一个简单的例子中.(在此示例中没有使用strings.xml或colors.xml,但它们应该用于实际项目)
<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>
Run Code Online (Sandbox Code Playgroud)
这个解决方案只有一个问题:页脚浮动在滚动视图上,如果没有足够的垂直空间,页脚将隐藏滚动视图的底部.
为了确保始终显示整个滚动视图,滚动视图的底部填充等于示例中的页脚高度(50dp):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="50dp" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
.......
</LinearLayout>
</ScrollView>
<include
android:layout_height="50dp"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
layout="@layout/footer" >
</include>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24331 次 |
| 最近记录: |