<ScrollView> 滚动视图的简单功能和用法
2016-06-04 16:38
471 查看
ScrollView是由Framelayout派生出来的,它就是一个用于为普通组件添加滚动条的组件.ScrollView里最多只能包含一个组件,而ScrollView的作用就是为组件添加垂直滚动条.
package com.crazyit.ui.scrollviewdemo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; /** * ScrollView 的功能与简单用法 */ public class ScrollViewActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scroll_view); } }
布局文件
<?xml version="1.0" encoding="utf-8"?> <!--定义ScrollView 为里面的组件添加垂直滚动条--> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.crazyit.ui.scrollviewdemo.ScrollViewActivity"> <HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="滚动视图滚动视图滚动视图滚动视图" android:textSize="30dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> </LinearLayout> </HorizontalScrollView> </ScrollView>
ScrollView组件里面 最多只能包含一个组件
相关文章推荐
- linux 启动流程图
- 关注java体系的技术方向
- 每天15min-HTML5(2)-第一个HTML程序
- 《Indy In Depth》中文版
- 时区与时间
- 买书优惠问题
- 用js操作表格
- window7 上安装 php扩展
- 利用x64_dbg破解一个最简单的64位小程序
- 关于onWindowFocusChanged
- NSRunLoop浅谈
- linux安装python2.7.11
- C++ Primer 面向对象编程 15.3 基类派生类相互转换 15.4. 构造函数和复制控制
- Gcd [Bzoj 2818]
- 注册的时候 输入框类用户名 密码 邮箱的判定
- Android系列之多线程用法与Service初步
- Minimum Depth of Binary Tree
- [JZOJ junior 2042] SuperPow
- 正则表达式 找邮箱
- 安卓HTTP实例中post方法和get方法的区别