Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic view with swiping horizontally and vertically

enter image description here

Please check above view

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.

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.

like image 821
Abhinav Singh Maurya Avatar asked Nov 11 '22 21:11

Abhinav Singh Maurya


1 Answers

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

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.

Here is my code

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;
like image 65
Amit Gupta Avatar answered Nov 14 '22 23:11

Amit Gupta