什么时候用 ScrollView ?

答:像以下这种情况,就是使用ScrollView;

摆放无顺序,无规律,并会超出屏幕的高度,就可以用ScrollView


错误的ScrollView示范,ScrollView只能包含一个孩子:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"> <ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="11" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="12" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="13" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="14" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="15" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="16" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="17" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="18" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="20" /> </ScrollView> </RelativeLayout>

错误的ScrollView示范,ScrollView只能包含一个孩子,包含多个就会报错(ScrollView只能包含一个孩子):


正确的示范:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"> <ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"> <!-- ScrollView里面只能包含一个孩子,才是正确的

Android-什么时候用ScrollView的更多相关文章

  1. android 滚动视图(ScrollView)

    为了可以让内嵌布局管理器之中加入多个显示的组件,而且又保证程序不这么冗余,所以可以通过 Activity程序进行控制,向内嵌布局管理器中添加多个组件. ScrollView提供一个显示的容器,可以包含 ...

  2. android用户界面之ScrollView教程实例汇总

    --------------------------汇总不容易啊------------------------------- 一.ScrollView基础知识 1.Android中ScrollVie ...

  3. Android长截屏-- ScrollView,ListView及RecyclerView截屏

    http://blog.csdn.net/wbwjx/article/details/46674157       Android长截屏-- ScrollView,ListView及RecyclerV ...

  4. android 开发-ListView与ScrollView事件冲突处理(事件分发机制处理)

    ListView和ScrollView都存在滚动的效果,所以一般不建议listView和scrollView进行嵌套使用,但有些需求则需要用到两者嵌套.在android的学习中学了一种事件分发处理机制 ...

  5. Android基础控件ScrollView滚动条的使用

    1.简介 ScrollView是一个FrameLayout的容器,不过在他的基础上添加了滚动,允许显示的比实际多的内容!另外,只能够往里面放置一个子元素,可以是单一的组件,又或者一个布局包裹着的复杂的 ...

  6. android 有弹性的ScrollView 简单实现,与处理ScrollView和ListView,GridView之间的冲突

    处理ScrollView和ListView,GridView之间的冲突, 最好的办法就是继承这两个类,重写他们的onMeasure方法即可: ListView: import android.widg ...

  7. android基础开发之scrollview

    scrollView 是android系统提供的一种 特殊的展示view. 其实我们很早就遇到过scrollview的东东,比如listview. 而google官方文档也提出,不要混合使用scrol ...

  8. Android实现两个ScrollView互相联动,同步滚动的效果

    公众号:smart_android 作者:loonggg 点击"阅读原文",可查看更多内容和干货 最近在做一个项目,用到了两个ScrollView互相联动的效果,简单来说联动效果意 ...

  9. android学习笔记11——ScrollView

    ScrollView——滚动条 用于内容显示不全,可提供滚动条下来形式,显示其余内容. ScrollView和HorizontalScrollView是为控件或者布局添加滚动条 特点如下: 1.只能有 ...

  10. Android中监听ScrollView滑动停止和滑动到底部

    1.监听ScrollView滑动停止: /********************监听ScrollView滑动停止*****************************/ scrollView.s ...

随机推荐

  1. 14_java之变量|参数|返回值|修饰符

    01java中的文档注释和制作 * A: 在eclipse使用时,可以配合文档注释,导出对类的说明文档,从而供其 他人阅读学习与使用. 通过使用文档注释,将类或者方法进行注释用@简单标注基本信息.如@ ...

  2. git之项目上传

    git之项目上传 需求:将项目代码上传至github 前期准备: 1.github账号注册 2.安装git环境,可以打开且使用git shell. 3.生成SSH key并与github账号绑定 步骤 ...

  3. WPF Grid 用 C# 代码后台设置

    WPF Grid 用 C# 代码后台设置 运行环境:Window7 64bit,.NetFramework4.61,C# 6.0: 编者:乌龙哈里 2017-02-21 参考: System.Wind ...

  4. 用Eclipse进行远程Debug代码

    在新的公司,由于项目很大,在本机运行会很慢,所以都是在本地开发,在远程虚拟机上运行.这样就让我痛苦了,我怎么在本地Eclipse上进行debug调试呢,但是在公司前辈的指导下让我知道了本地Eclips ...

  5. 搭建Git Server - Centos+Gitosis

    参考并部分转载自:http://www.pfeng.org/archives/757 1. 安装依赖 yum -y install curl-devel expat-devel gettext-dev ...

  6. Django中的DRF框架视图集使用

    1. 两个基类 1)APIView Django REST_framework 中所有视图的基类是APIView   父类是View 支持定义的属性: authentication_classes 列 ...

  7. spring 采用编程式事务

    1.getCurrentSession()与openSession()的区别? * 采用getCurrentSession()创建的session会绑定到当前线程中,而采用openSession() ...

  8. java 修改文件

    public void fileAlter(String fileName,String content) throws IOException{                 BufferedRe ...

  9. AssetBundle依赖

    [Managing asset dependencies] 一个Asset会依赖其它Asset.可以把一个Asset所依赖的Asset也打包进自己的AssetBundle.可是多个Asset可能依赖同 ...

  10. 【sdut2878】Circle

    题目链接http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index/problemdetail/pid/2878.html 题意 n个结点编号为0 ...