<ViewFlipper android:id="@+id/vf_help" android:layout_width="match_parent" android:layout_height="match_parent" android:flipInterval="3000" android:inAnimation="@anim/right_in" android:outAnimation="@anim/right_out"> <include layout="@layout/page_help_one" /> <include layout="@layout/page_help_two" /> <include layout="@layout/page_help_three" /> <include layout="@layout/page_help_four" /> </ViewFlipper>
mVfHelp = (ViewFlipper) findViewById(R.id.vf_help);
for (int i = 0; i < resId.length; i++) {
mVfHelp.addView(getImageView(resId[i]));
}
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="1000" android:fromXDelta="100%p" android:toXDelta="0" /> </set>
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="1000" android:fromXDelta="0" android:toXDelta="-100%p" /> </set>
<?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:orientation="vertical"> <ViewFlipper android:id="@+id/vf_help" android:layout_width="match_parent" android:layout_height="match_parent" android:flipInterval="3000" android:inAnimation="@anim/right_in" android:outAnimation="@anim/right_out"> <include layout="@layout/page_help_one" /> <include layout="@layout/page_help_two" /> <include layout="@layout/page_help_three" /> <include layout="@layout/page_help_four" /> </ViewFlipper> </LinearLayout>
public class MethodOneActivity extends BaseActivity {
private ViewFlipper mVfHelp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_method_one);
mVfHelp = (ViewFlipper) findViewById(R.id.vf_help);
mVfHelp.startFlipping();
}
}
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="1000" android:fromXDelta="-100%p" android:toXDelta="0" /> </set>
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="1000" android:fromXDelta="0" android:toXDelta="100%p" /> </set>
<?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:orientation="vertical"> <ViewFlipper android:id="@+id/vf_help" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>
private void initData() {
//实例化SimpleOnGestureListener与GestureDetector对象
mgListener = new MyGestureListener();
mDetector = new GestureDetector(mActivity, mgListener);
//动态添加子View
for (int i = 0; i < resId.length; i++) {
mVfHelp.addView(getImageView(resId[i]));
}
}
/**
* @Description 重写onTouchEvent触发MyGestureListener里的方法
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
return mDetector.onTouchEvent(event);
}
/**
* @Description 自定义一个View类下的GestureDetector
*/
private class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float v, float v1) {
if (e1.getX() - e2.getX() > MIN_MOVE) {
mVfHelp.setInAnimation(mActivity, R.anim.right_in);
mVfHelp.setOutAnimation(mActivity, R.anim.right_out);
mVfHelp.showNext();
} else if (e2.getX() - e1.getX() > MIN_MOVE) {
mVfHelp.setInAnimation(mActivity, R.anim.left_in);
mVfHelp.setOutAnimation(mActivity, R.anim.left_out);
mVfHelp.showPrevious();
}
return true;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有