Android 输入表单实例--上下固定,中部滚动布局
来源:互联网 发布:寰神结剧情知乎 编辑:程序博客网 时间:2024/05/19 06:46
使用的控件有:
RelativeLayout 相对布局ScrollView 滚动视图
TableLayout 表格布局
如上图所示,界面(或者说窗体)分为三个部分:
顶部:信息提示,标题(Title)
实现这样的布局一定要用到RelativeLayout 相对布局,我们这样指定我的布局。
1.根控件(视图)放置一个RelativeLayout 作为根控件。指示它填充满整个窗口,fill_parent。
2.在根控件里放置三个子控件,对应刚刚提到三个部分(顶部,中间。底部)等。
3.分别设定上面三个控件的布局属性(或者说设置布局,对齐样式)。
我们设定顶部控件的相对属性为:android:layout_alignParentTop="true",这个属性意思是对齐到父控件的顶部
然后设定底部控件的属性为:android:layout_alignParentBottom="true",指定它对齐到父控件的底部再指定中间的控件属性为:
android:layout_below ="@id/toppanel" ,指示它位于某个控件下方。在这里肯定是上面提到的 顶部控件 了。
android:layout_above="@id/panelBottom",指示它位于某个控件上方。在这里肯定是上面提到的 底控件 了。布局初步完成。贴代码
java代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:id="@+id/toppanel"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="用户信息表单(顶部)"
android:textSize="11pt"
/>
</RelativeLayout>
<RelativeLayout android:id="@+id/panelBottom"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content">
<Button a
ndroid:text="Save(底部控件)"
android:id="@+id/button1"
android:layout_height="wrap_content"
android:layout_width="fill_parent"></Button>
</RelativeLayout>
<ScrollView
android:layout_below ="@id/toppanel"
android:layout_above="@id/panelBottom"
android:layout_width="wrap_content" android:layout_height="wrap_content"
>
<....这里将写中间部分的控件....>
</ScrollView>
</RelativeLayout>
顶部控件使用一个RelativeLayout 名字是:toppanel
底部控件使用一个RelativeLayout 名字是:panelBottom
中间控件使用一个ScrollView,滚动视图控件。该控件的好处是当它的子控件太长时,会自动出现滚动条。
下面我们为ScrollView下添加一个TableLayout,这个一个表格布局控件,使得布局非常整齐。
java代码:
<TableLayout android:padding="3dip"
android:id="@+id/tableLayout1"
android:layout_width="fill_parent"
android:stretchColumns="1"
android:layout_height="fill_parent">
<TableRow >
<TextView android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="right"
android:textStyle="bold"
android:padding="3dip"
android:text="User">
</TextView>
<EditText android:id="@+id/editText1"
android:padding="3dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></EditText>
</TableRow>
</TableLayout>
- Android 输入表单实例--上下固定,中部滚动布局
- Android 输入表单实例--上下固定,中部滚动布局
- 上下固定,中部滚动布局
- flex上下固定中间滚动布局
- 上下固定,中间可滚动
- Axure动态布局,中部加入滚动条
- android textView 上下滚动
- android界面:上下固定且中间内容滚动的页面制作
- css布局(上下固定,中间自适应)
- 表头,上下滚动时固定,左右滚动时自动对齐
- Android上下布局
- table的表头固定--上下滚动表头固定,左右滚动跟随滚动
- android-RelativeLayout实现顶部、中部、底部布局
- 当页面类似于表单,有很多需要输入的内容,就需要做上下滚动的效果
- android实现左右上下滚动
- android 页面文字上下滚动
- Android 实现上下滚动TextSwitcher
- Android 禁止RecyclerView 上下滚动
- VS快捷键教程
- LeetCode | Spiral Matrix
- JavaScript中的匿名函数、回调函数、自调用函数
- 表格一条线
- Reverse Integer
- Android 输入表单实例--上下固定,中部滚动布局
- tar.bz2更快编解码方式
- awk 处理多个文件
- Android仿QQ空间底部菜单
- Windows Azure 安全最佳实践 - 第 7 部分:提示、工具和编码最佳实践
- HDU 2578 Dating with girls(1)
- Redis复制与可扩展集群搭建——Redis学习笔记(四)
- 对fram,boundls的一些理解(3)
- 中文ubuntu里用户目录里的路径改成英文