Android学习之路--布局二
来源:互联网 发布:专业篮球教学软件 编辑:程序博客网 时间:2024/06/08 12:47
ScrollView
使用
HorizontalScrollView
使用
ScrollView的使用:在某些页面布局下,如果里面的组件过多,而现有布局又不支持滑动,导致后面的组件看不到,那么我们可以用ScrollView来进行填充。例如:
<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TableLayout android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="第一排" /> <TableRow> <TextView android:id="@+id/tv_one" android:layout_width="match_parent" android:layout_height="500dp" android:background="#bd0708" android:gravity="center" android:padding="5dp" android:text="我是第一个组件" /> <TextView android:id="@+id/tv_two" android:layout_width="match_parent" android:layout_height="500dp" android:background="#666" android:gravity="center" android:padding="5dp" android:text="我是第二个组件" /> <TextView android:id="@+id/tv_three" android:layout_width="match_parent" android:layout_height="500dp" android:background="#999" android:gravity="center" android:padding="5dp" android:text="我是第二个组件" /> </TableRow> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="第二排" /> <TableRow> <TextView android:layout_width="match_parent" android:layout_height="500dp" android:background="#bd0708" android:gravity="center" android:padding="5dp" android:text="我是第一个组件" /> <TextView android:layout_width="match_parent" android:layout_height="80dp" android:background="#666" android:gravity="center" android:padding="5dp" android:text="我是第二个组件" /> <TextView android:layout_width="match_parent" android:layout_height="80dp" android:background="#999" android:gravity="center" android:padding="5dp" android:text="我是第二个组件" /> </TableRow> </TableLayout> </LinearLayout></ScrollView>
注意:在使用ScrollView时,里面子布局只能有一个Layout包括起来。否则会报:ScrollView can host only one direct child错误。
同理HorizontalScrollView也是一样。
这一篇顺便测试一下目录生成。
如果布局还有些疑问的话,欢迎请看 Android 学习之路--布局篇
0 0
- Android学习之路--布局二
- android学习之二 五大布局
- Android学习系列(二)--App布局初探之简单模型
- Android 自定义控件学习之二 简单布局实例
- Android学习笔记之RecyclerView(二)-异布局Item实现
- Android学习笔记二十五之ListView多布局实现
- Android学习笔记二十五之ListView多布局实现
- Android 常用布局 -- Android 学习之路
- 学习android之布局
- Android学习之布局
- android布局之二:布局复用
- Android深入浅出之二(布局)
- Android学习之路--布局篇
- Android学习之路--布局优化
- Android学习系列(二)布局管理器之线性布局的3种实现方式
- android布局之GridView布局学习小结
- Android学习-五布局之线性布局
- Android学习-五布局之相对布局
- 我的排序,输入n个数,然后进行升降排序
- 现阶段对于编程学习的想法
- 重温一下 JAVA 集合框架
- mysql-5.6.24-win32免安装配置方法
- 集合框架_用LinkedList实现栈结构的集合代码、LinkedList模拟栈数据结构的集合并测试案例
- Android学习之路--布局二
- 使用PXE+DHCP+Apache+Kickstart无人值守安装linux
- 输入输出时关于缓冲区的一点问题
- CodeForces - 598A
- http 协议重要知识点
- js中的数据类型
- Linux实战教学笔记02:计算机系统硬件核心知识
- JAVA-注释详解
- ACM篇:POJ 2676 -- Sudoku