首页 > 其他 > 详细

HorizontalScrollView水平滚动控件

时间:2016-04-18 22:13:00      阅读:262      评论:0      收藏:0      [点我收藏+]

   一、HorizontalScrollView控件只是支持水平滚动,而且它只能包含一个控件,通常是在< HorizontalScrollView >标签中定义了一个<LinearLayout>

标签并且在<LinearLayout>标签中android:orientation属性值设置为horizontal,然后在<LinearLayout>标签中放置多个控件,如果<LinearLayout>标签中的控件所占用的总宽度超出屏幕的宽度,就会出现滚动效果
  二、下面是实例:
技术分享
在main.xml文件中:
 1 <?xml version="1.0" encoding="utf-8"?>
 2 <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
 3     android:layout_width="fill_parent" android:layout_height="wrap_content">
 4 
 5     <LinearLayout android:orientation="horizontal"
 6         android:layout_width="fill_parent" android:layout_height="fill_parent">
 7 
 8         <ImageView android:layout_width="wrap_content"
 9             android:layout_height="wrap_content" android:src="@drawable/item1"></ImageView>
10         <ImageView android:layout_width="wrap_content"
11             android:layout_height="wrap_content" android:src="@drawable/item2"></ImageView>
12 
13         <ImageView android:layout_width="wrap_content"
14             android:layout_height="wrap_content" android:src="@drawable/item3"></ImageView>
15 
16         <ImageView android:layout_width="wrap_content"
17             android:layout_height="wrap_content" android:src="@drawable/item4"></ImageView>
18 
19         <ImageView android:layout_width="wrap_content"
20             android:layout_height="wrap_content" android:src="@drawable/item5"></ImageView>
21     </LinearLayout>
22 </HorizontalScrollView>

.java文件没有加入代码.

运行结果:

技术分享

注意:水平方向出现滑动条

 

HorizontalScrollView水平滚动控件

原文:http://www.cnblogs.com/SoulCode/p/5405990.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!