什么时候用 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. 五、配置jenkins定时构建或上游job触发构建

    我们之前说的都是通过检测github是否有push动作,即代码是否有更新,一旦检测到push动作就出发jenkins构建: 但是除了这种方式,我们可能还会需要定时进行构建,比如在每天的凌晨1:00构建 ...

  2. 前端开发之JavaScript基础篇三

    主要内容: 1.创建对象的几种方式 2.JavaScript内置对象 3.JavaScript错误--Throw.Try 和 Catch 4.JavaScript 表单验证 一.创建对象的几种方式 1 ...

  3. resultset 记录数

    JDBC中的ResultSet API没有直接获取记录条数的方法,现介绍几个: 方法一:利用ResultSet的getRow方法来获得ResultSet的总行数 Java代码 ResultSet rs ...

  4. etcd raft library

    https://github.com/coreos/etcd/tree/master/raft import "github.com/coreos/etcd/raft" ----- ...

  5. new 约束

    [new 约束] new 约束指定泛型类声明中的任何类型参数都必须有公共的无参数构造函数.如果要使用 new 约束,则该类型不能为抽象类型. 当泛型类创建类型的新实例,请将 new 约束应用于类型参数 ...

  6. Spark scala和java的api使用

    1.利用scala语言开发spark的worcount程序(本地运行) package com.zy.spark import org.apache.spark.rdd.RDD import org. ...

  7. 【ZOJ3329】One Person Game

    题意 你有三枚色子,第i个色子有ki面,你有一个计数器. 1.开始的时候将计数器调至0 2.扔三个色子,如果色子1是a,色子2是b,色子3是c,则将计数器归零.否则计数器加上三个色子的和. 3.如果计 ...

  8. python解析pcap文件中的http数据包

    使用scapy.scapy_http就可以方便的对pcap包中的http数据包进行解析 scapy_http可以在https://github.com/invernizzi/scapy-http下载, ...

  9. Crack IDEA

    使用破解补丁 Crack IDEA→在http://idea.lanyus.com/上可以找到最新的破解补丁,下载并放到软件的bin目录下 →更改bin目录下的两个文件:Idea.exe.vmopti ...

  10. 返回JSON到前台的对象属性设置

    1.项目中使用JSON的第三方架包:jackson-annotations-2.8.0.jar 2.可以将对象的属性返回进行相应的处理 比如格式化时间.密码敏感等属性 如:User.java pack ...