介绍
如何Android项目中使用ViewFlipper与GestrueDetector实现滑屏效果?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
1.主要。xml
& lt;及# 63;xml version=?.0”;编码=皍tf-8", # 63;比; http://schemas.android.com/apk/res/android" & lt; LinearLayout xmlns: android=?; android: layout_width=癴ill_parent" android: layout_height=癴ill_parent" android:背景=癅drawable/bg" android:取向=皏ertical"比; & lt; ViewFlipper android: id=癅 + id/viewFlipper1" android: layout_width=癴ill_parent" android: layout_height=癴ill_parent" android: persistentDrawingCache=癮nimation" android: flipInterval=?000”; android:没有生命=癅anim/push_left_in" android: outAnimation=癅anim/push_left_out" 比; & lt;包括android: id=癅 + id/lay1"布局=癅layout/layout1"/比; & lt;包括android: id=癅 + id/lay2"布局=癅layout/layout2"/比; & lt;/ViewFlipper> & lt;/LinearLayout>
注:layout1和layout2布局很简单,就是有一个textview和一个按钮,就不在这里写出了。其中包含了两个特效xml文件,放在res/动画下
1。push_left_in
& lt;及# 63;xml version=?.0”;编码=皍tf-8", # 63;比; & lt;设置xmlns: Android=癶ttp://schemas.android.com/apk/res/android"比; & lt;翻译 android: fromXDelta=皃" 100%; android: toXDelta=?”; android:持续时间=?00“/比; & lt;α android: fromAlpha=?.0”; android: toAlpha=?.0”; android:持续时间=?00”;/比; & lt;/set>
2 push_left_out
& lt;及# 63;xml version=?.0”;编码=皍tf-8", # 63;比; & lt;设置xmlns: android=癶ttp://schemas.android.com/apk/res/android"比; & lt;翻译 android: fromXDelta=?”; android: toXDelta=皃" -100%; android:持续时间=?00“/比; & lt;α android: fromAlpha=?.0”; android: toAlpha=?.0”; android:持续时间=?00”;/比; & lt;/set>
主类:
包com.wj.gesture; 进口android.app.Activity; 进口android.os.Bundle; 进口android.view.GestureDetector; 进口android.view.GestureDetector.OnDoubleTapListener; 进口android.view.GestureDetector.OnGestureListener; 进口android.view.MotionEvent; 进口android.view.View; 进口android.view.View.OnClickListener; 进口android.view.View.OnTouchListener; 进口android.view.animation.AccelerateInterpolator; 进口android.view.animation.Animation; 进口android.view.animation.TranslateAnimation; 进口android.widget.Button; 进口android.widget.TextView; 进口android.widget.Toast; 进口android.widget.ViewFlipper; 公共类GestureDetectorTest扩展活动实现>关于如何Android项目中使用ViewFlipper与GestrueDetector实现滑屏效果问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。如何Android项目中使用ViewFlipper与GestrueDetector实现滑屏效果