【Android 开发】:UI控件之 ScrollView垂直滚动控件 和 HorizontalScrollView水平滚动控件的使用
来源:互联网 发布:重庆生活频道 网络直播 编辑:程序博客网 时间:2024/05/01 20:40
1. ScrollView 垂直滚动控件的使用
ScrollView控件只是支持垂直滚动,而且在ScrollView中只能包含一个控件,通常是在< ScrollView >标签中定义了一个<LinearLayout>标签并且在<LinearLayout>标签中android:orientation属性值设置为vertical,然后在<LinearLayout>标签中放置多个控件,如果<LinearLayout>标签中的控件所占用的总高度超出屏幕的高度,就会在屏幕的右侧出现一个滚动条。
案例实现:
1) 布局文件
<?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: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" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/item1" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="显示多张图片" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/item2" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/item3" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/item4" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/item5" /> </LinearLayout></ScrollView>
2) 因为是UI上的布局小Demo,所以主程序代码不需要实现什么功能,直接编译执行结果如下所示:【注意】:android:src 表示设置图片源
2. HorizontalScrollView 水平滚动控件的使用
HorizontalScrollView控件只是支持水平滚动,而且它只能包含一个控件,通常是在< HorizontalScrollView >标签中定义了一个<LinearLayout>
标签并且在<LinearLayout>标签中android:orientation属性值设置为horizontal,然后在<LinearLayout>标签中放置多个控件,如果<LinearLayout>标签中的控件所占用的总宽度超出屏幕的宽度,就会出现滚动效果
案例实现
1) 布局文件
<?xml version="1.0" encoding="utf-8"?><HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/item1" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/item2" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/item3" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/item4" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/item5" /> </LinearLayout></HorizontalScrollView>
程序执行结果:
源码下载地址:http://download.csdn.net/detail/xukunhui2/5527257
- 【Android 开发】:UI控件之 ScrollView垂直滚动控件 和 HorizontalScrollView水平滚动控件的使用
- [Android] ScrollView 垂直滚动控件和 HorizontalScrollView 水平滚动控件的使用
- HorizontalScrollView 水平滚动控件
- Android HorizontalScrollView和ScrollView 水平滚动 垂直滚动
- ScrollView 控件支持垂直滚动
- Android控件之HorizontalScrollView 去掉滚动条
- Android控件之HorizontalScrollView 去掉滚动条
- Android控件之HorizontalScrollView 去掉滚动条
- 安卓控件使用系列23:HorizontalScrollView 水平滚动控件的使用方法
- UI控件之ScrollView(滚动条)
- android 水平滚动ScrollView: HorizontalScrollView
- android 图片垂直方向( ScrollView) ,水平方向HorizontalScrollView 滚动
- Android 垂直与水平滚动条:Scrollview与HorizontalScrollView
- Android 垂直与水平滚动条:Scrollview与HorizontalScrollView
- 安卓控件使用系列22:ScrollView垂直滚动控件的使用方法
- Android控件之ScrollView(滚动视图)
- android水平循环滚动控件
- IOS ScrollView滚动控件使用
- win7 64位安装pomelo 惊魂记
- DirectX 3D_实践之DirectX3D中网格的使用
- GDB 命令详细解释【转】
- Markdown and Pando
- UBI文件系统制作
- 【Android 开发】:UI控件之 ScrollView垂直滚动控件 和 HorizontalScrollView水平滚动控件的使用
- 在Linux中开机自动运行普通用户脚本程序
- test
- arcgis api for flex 开发入门(一)环境搭建
- 用Visual C++.NET进行GDI+编程
- arcgis api for flex 开发入门(二)map 的创建
- getch
- uva 10905-Children’s Game
- WSAEventSelect模型中FD_READ 网络事件的处理