水平和垂直滑动的动态视图 [英] Dynamic view with swiping horizontally and vertically

查看:22
本文介绍了水平和垂直滑动的动态视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请检查上面的视图

我必须相应地创建一个视图,当我们从左到右滑动时,图像将与从右到左相同.当我从上到下滑动时,会出现一个网络视图,并且会从下到上滑动图像.图像和网址等所有数据都是动态的,数据将来自服务器.此外,我必须应用 pull 来刷新其中的概念.

I have to create a view accordingly, where when we slide left to right images will come same as right to left. When I slide top to bottom a web view will come and sliding bottom to top images will come. All the data like images and web url will be dynamic and data will come from server. Also I have to apply pull to refresh concept in it.

我已经浏览了 this 链接并成功实现了它,但它不是相应的,它有许多限制.

I have gone through this link and successfully implemented it but its not accordingly and it have many limitations.

请让我知道这种观点是否可行.

Please let me know that if this kind of view is possible or not.

推荐答案

有一种方法可以在不使用任何库的情况下做到这一点.

There is a way to do this with out using any lib.

在您的 xml 文件中设计另一个布局,然后放置您要在滑动时显示的所有小部件,然后根据需要应用从左到右和从上到下的滑动动画.之后,借助手势检测器,您可以获得滑动事件,并执行您的任务.

In your xml file design another layout and put all the widget which you want to show at the time of sliding after that apply sliding animation like left to right and up to down as you want. After that with the help of gesture detector you can get the event of sliding, and perform your task.

这是我的代码

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>

用于动画的类文件中的代码

Code used in class file for animation

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;

这篇关于水平和垂直滑动的动态视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆