ama*_*ski 3 android footer scrollview relativelayout bottom-up
我希望页脚锚定在屏幕的底部,当且仅当它可以锚定在那里而不重叠任何其他视图.
问题是我不知道将多少视图添加到页眉或页脚.
如果将页脚放在窗口底部会使其重叠,我想将页脚放在scrollview的底部.(也许通过将它添加到RelativeLayout并使用它需要在顶部组件下方的规则?)
这是我想要获得的图片:
哪里:
1)RelativeLayout包含顶部的TableLayout和底部的LinearLayout.
2)当TableRows添加到TableLayout时,TableLayout向下扩展.
3)当视图添加到它时,LinearLayout从底部扩展.
~~~
我希望scrollview的大小增加到足以适合组件而不重叠.
提前感谢您提供如此棒的社区支持
Sal*_*alw 10
我认为你可以在线性布局中解决它.您在线性布局中设置了三个块:标题,正文,页脚.将body设置为fill_parent和layout_weight = 1,这样主体将展开以填充页眉和页脚从父项中获取其后的内容.整个结构放入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>
Run Code Online (Sandbox Code Playgroud)
我在Android 2.1的模拟器中进行了测试,它看起来很有效.
| 归档时间: |
|
| 查看次数: |
2363 次 |
| 最近记录: |