功能:点击滚动的图片,上面的imageswitcher显示选择的大图。
ImageSwitcher:显示图片区域的控件
Gallery:控制图标列表索引。
(1) Gallery控件也可译为画廊组件,主要用于横向显示图像列表。Gallery类的继承结构Spinner有共同的父类:AbsSpinner。从某种意义上来说,Gallery和Spinner都是一个列表框,只不过Spinner是一个垂直显示的列表模型,而Gallery则是一个水平显示的列表框。
(2) Gallery主要是通过用户拖动来展示一组图片或其它组件,Spinner则是提供选择让用户选择。为它提供一个内容SimpleAdapter,该Adapter的getView()方法返回的View将作为Gallery组件的列表项。
属性:
animationDuration:布局变化时动画转换所需时间(毫秒)。动画开始时计时。该值必须是整数,比如:100。
spacing:设置设置图片之间的间距.
unselectedAlpha:设置未选中的条目的透明度(Alpha)。该值必须是float类型,“1.2”
Gravity:
top紧靠容器顶端 bottom紧靠容器底部 left紧靠容器左侧,不改变其大小
right紧靠容器右侧 center_vertical垂直居中 fill_vertical垂直方向上拉伸至充满容器
center_horizontal水平居中 Fill_horizontal水平方向上拉伸使其充满容器
center居中对齐 fill在水平和垂直方向上拉伸,使其充满容器
clip_vertical垂直剪切(当对象边缘超出容器的时候,将上下边缘超出的部分剪切掉)
clip_horizontal水平剪切(当对象边缘超出容器的时候,将左右边缘超出的部分剪切掉)
xml布局代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
< RelativeLayout 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" >
< ImageSwitcher
android:id = "@+id/imageSwitcher1"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:background = "#000000"
>
</ ImageSwitcher >
< Gallery
android:id
|