ScrollView是一个滚动条控件,当屏幕中内容很多时候需要使用滚动条。ScrollView类的继承图如下:
java.lang.Object
↳android.view.View
↳android.view.ViewGroup
↳android.widget.FrameLayout
↳android.widget.ScrollView
android.widget.ScrollView继承了android.widget.FrameLayout框架布局类。ScrollView例子如图7-9所示滚动条例子。
图7-9 Scrollview
布局文件请参考代码清单7-10,完整代码请参考chapter7_1工程中scrollview_1.xml代码部分(chapter7_1/res/layout/scrollview_1.xml)。
【代码清单7-10】
<?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="wrap_content">
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello"
android:textSize="20dip" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/content" />
</LinearLayout>
</ScrollView>
ScrollView有很多属性管理它的样式,如果在xml中设置,可以在<ScrollView >标签内设置滚动条样式的属性:
• android:scrollbars="none",不显示滚动条,但能够滚动的;
• android:scrollbarSize,滚动条大小。
修改上面的例子添加这些属性xml布局文件代码如下:
<?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="wrap_content"
android:scrollbarSize="12dip"
android:scrollbars="none"
>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello"
android:textSize="20dip" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/content" />
</LinearLayout>
</ScrollView>
出自《Android开发案例驱动教程》第七章
- 大小: 36.2 KB
分享到:
相关推荐
VMware7.1.4安装CentOS-5.5 Linux详解过程全记录,包括详尽的文字和图片说明,能使您快速方便的安装该虚拟机,文中采用图形安装形式,包括对安装过程中对系统的详细设置,硬盘分区,软件加载设置等,为您的Linux之旅...
vmware workstation full 7.1.4 序列号
plsql developer 7.1.4注册码
PL SQL Developer 7.1.4 汉化包 可用本人亲测。
书以国内外先进的企业信息基础架构为主线进行讲解,每个知识点在讲解时都与实例相结合,力求使读者 能够通过真实的案例达到触类旁通、举一反三。若读者的企业没有采用本书的案例部署,那么读者可以根 据自身的情况,...
plsqldev_7.1.4汉化补丁
vmware7.1.4可用序列号
VMware_Workstation7.1.4 专用的VMware虚拟机程序,是老版的,的有地方很可能用到,下载保存了。
VMware_Workstation_7.1.4_385536+完美汉化包
VMware.Workstation.v7.1.4
VM_7.1.4 build-385536_cn_汉化另附赠 vm7.1.3 、vm7.1.4以及vm8 注册码 最近重装系统 win7+vm8 后虚拟机总是出问题,于是改装vm7,总结了下感受:vn7简洁...本软件为VM_7.1.4 build-385536 汉化, 挺好用的 分享给大家
plsqldev7.1.4,Oracle工具,很好很强大
PL\SQL Developer7.1.4破解文件
斑马打印机驱动程序zebra_7.1.4,斑马打印机驱动程序zebra_7.1.4
VMware WorkstationV7.1.4 汉化补丁 汉化绿色免费版
VMware Workstation7.1.4 汉化破解包,方便好用!
VMware.Workstation.v7.1.4
VMware+Workstation+7.1.4注册机和完美汉化包
VMware Workstation7.1.4完美汉化包使用说明 1.安装原始版本。 2.解压汉化文件。把汉化文件直接复制到虚拟机文件夹中,替 换原文件即可。 3.替换时,个别文件可能提示无法替换,请在任务管理器中先 结束相应...