知识点:
1.ViewFlipper基本用法及动态添加View;
2.ViewFlipper结合手势翻页+特效;
3.WindowManager的基本用法。
任意张图片实现循环滑动,其实PageFlipper当前最多的子View个数(ChildViewCount)小于等于2.
源码路径:http://download.csdn.net/detail/zhouyuanjing/4764619
fliper_item.xml:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center" >
- <ImageView
- android:id="@+id/img"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:gravity="center" />
- </LinearLayout>
main.xml:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
- <ViewFlipper
- android:id="@+id/myViewFlipper"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" >
- </ViewFlipper>
- </LinearLayout>
MainActivity.java: