控件属性设置:
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
26
27
28
29
30
31
32
33
34
|
<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"
tools:context=
".MainActivity"
>
<ViewFlipper
android:id=
"@+id/viewFlipper1"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:flipInterval=
"3000"
android:inAnimation=
"@anim/push_down_in_no_alpha"
android:outAnimation=
"@anim/push_down_in_no_alpha"
android:layout_alignParentLeft=
"true"
android:layout_alignParentTop=
"true"
>
<ImageView
android:id=
"@+id/imageView1"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:scaleType=
"fitXY"
android:src=
"@drawable/photo1"
/>
<ImageView
android:id=
"@+id/imageView2"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:scaleType=
"fitXY"
android:src=
"@drawable/photo2"
/>
<ImageView
android:id=
"@+id/imageView3"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:scaleType=
"fitXY"
android:src=
"@drawable/photo3"
/>
</ViewFlipper>
</RelativeLayout>
|
启动ViewFlipper:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
public
class
MainActivity
extends
Activity
{
/*
* ViewFlipper幻灯片主要属性:
* android:flipInterval="3000" 延迟时间
* android:inAnimation="@android:anim/slide_in_left" 进入动画
* android:outAnimation="@android:anim/slide_out_right" 退出动画
*/
@Override
protected
void
onCreate(Bundle savedInstanceState)
{
super
.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ViewFlipper viewFlipper = (ViewFlipper) findViewById(R.id.viewFlipper1);
viewFlipper.startFlipping();
}
}
|
本文转自 glblong 51CTO博客,原文链接:http://blog.51cto.com/glblong/1226235,如需转载请自行联系原作者