请检查上面的视图
我必须相应地创建一个视图,当我们从左向右滑动时,图像将与从右向左滑动相同。当我从上到下滑动时,将会出现网络视图,并且从下到上滑动图像将会出现。所有数据(例如图像和网址)都是动态的,并且数据将来自服务器。我还必须在其中应用拉动刷新概念。
我已经经历过this链接并成功实施了它,但它并不相应,并且有很多限制。
请告诉我这种观点是否可能。
有一种方法可以在不使用任何库的情况下做到这一点。
在你的xml文件中设计另一个布局,并放置你想要在滑动时显示的所有小部件,然后根据需要应用从左到右、从上到下的滑动动画。之后,借助手势检测器,您可以获取滑动事件,并执行您的任务。
这是我的代码
Animation Left slide
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromXDelta="100%"
android:toXDelta="0%" >
</translate>
Animation Right slide
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromXDelta="-100%"
android:toXDelta="0%" >
</translate>
Animation Slide up
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromYDelta="100%"
android:toYDelta="0%" >
</translate>
Animation Slide Down
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="500"
android:fromYDelta="-100%"
android:toYDelta="0%" >
</translate>
动画类文件中使用的代码
case SimpleGestureFilter.SWIPE_RIGHT:
ScreenAnimation.setVisibility(View.VISIBLE);
ScreenAnimation.startAnimation(RightSwipe);
break;
case SimpleGestureFilter.SWIPE_LEFT:
ScreenAnimation.setVisibility(View.VISIBLE);
break;
case SimpleGestureFilter.SWIPE_DOWN:
ScreenAnimation.setVisibility(View.VISIBLE);
ScreenAnimation.startAnimation(DownSwipe);
break;
case SimpleGestureFilter.SWIPE_UP:
ScreenAnimation.setVisibility(View.VISIBLE);
ScreenAnimation.startAnimation(UpSwipe);
break;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)