什么时候用 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. Flask之模板之特殊变量和方法

    3.6 Flask中的特殊变量和方法: 在Flask中,有一些特殊的变量和方法是可以在模板文件中直接访问的. config 对象: config 对象就是Flask的config对象,也就是 app. ...

  2. SpringMVC关于json、xml自动转换的原理研究[附带源码分析](使用JAXB转换XML)

    前言 SpringMVC是目前主流的Web MVC框架之一. 如果有同学对它不熟悉,那么请参考它的入门blog:http://www.cnblogs.com/fangjian0423/p/spring ...

  3. vertex shader(1)

    Vertex shader Architecture: 所有在vertex shader中的数据都用128-bit的quad-floats表示(4x32-bit). vertex shader线性地执 ...

  4. .NET高级工程师逻辑面试题

    1.面试题 有5座连续相邻的房子,并且每个房子有同的颜色:蓝色,绿色,红色,白色和黄色 每间房子的主人有不同的国籍:英国.印尼.德国.美国和荷兰 每个人喝不同的饮料:葡萄汁.咖啡.牛奶.茶和水 每个人 ...

  5. linux进阶与hadoop

    Linux进阶命令: find .  | ls --help | more  grep ll | grep 1.txt   grep -ri  BASH 1.txt   grep -ri BASH   ...

  6. C#自省

    [C#自省] 1.根据string,获取type.Type.GetType 方法,获取具有指定名称的 Type,执行区分大小写的搜索. 2.根据obj,获取type.Object.GetType 方法 ...

  7. Python中的try...except...finally

    Python的异常处理代码格式如下: try: // do something except Exception as e: // dual with exception finally: // fi ...

  8. Unity strip engine code 遇到執行不能之問題與解決

    遊戲發布在 WebGL 平台發現檔案還是太大,因此在 IL2CPP 的環境下,開啟 Strip engine code 編譯功能,嘗試看看能不能減少一些檔案容量. 但由於我們另外有載入 Scene s ...

  9. shell编程之sed语法

    首先插播条广告:  想要进一个文件夹去 看下面有那些文件 必须对这个文件夹有执行权限. sed p  打印对应的行  2p 打印第二行. -n  只输出经过sed 命令处理的行 看图吧 不太会擅长言语 ...

  10. Linux的作业管理

    一.作业管理的场景 作业管理(job control)是在bash环境下使用的,主要使用在同一个bash中管理多个作业的场景,譬如登录bash之后想同时复制文件.数据搜索,编译. 但是bash的作业管 ...