Create "no more scroll possible" effect for HorizontalScrollView - android

An android WebView and some other views have a nice animation effect of "no more scroll possible" - nice blue filled arc animating with the direction of your finger if you try to scroll after the max scrolling reached. The arc animates as you move the finger and smoothly disappears when you remove/stop the finger. In order to see it, just go to device Settings and try to scroll beyond the maximum.
I'd like to implement the same effect for my HorizontalScrollView.
Please pay attention, it is NOT about fading edge (AFAIK).
Please advise.
Thanks

The HorizontalScrollview should behave like this by default. But what you can try is adding this to your HorizontalScrollview in XML:
android:overScrollMode="always"
or add this to your code:
yourHorizontalScrollview.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
So it will always show the animation left or right depending on the direction you scroll.

Related

Animation - Zoom in & out animation of image while swiping a layout left to right in android

I haven't worked on animation. Can anyone let me know how to zoom in & zoom out a image when we swipe it from left or right using vertical layout in android.
The above animation exist in ios.
I can able to swipe linear layout left and right but need some animation while moving the image (inside linear layout) from left to right.
Animation should be like, if the left image moved to center then the
image should be zoomed in/look bigger and vice versa to right image.
left & right image should be zoomed out. Thanks in advance.
This is part of the transition APIs.
https://developer.android.com/training/transitions/
or if all the layouts that you want to animate are part of the same activity then you should go with the property animation APIs
https://developer.android.com/guide/topics/graphics/prop-animation
This is a sample zoom animation
https://developer.android.com/training/animation/zoom
Have fun, hope I've been of some help

Logic behind startScroll in scroller?

I don´t get the idea of startScroll() in this documentation.
It says:
Positive numbers will scroll the content to the left.
I don´t get it. If 0 is always on the left why scroll positive to the left? And if negative it will scroll to the right.
But why? It´s just so hard to wrap my head around it. What´s the logic behind it? Why make positive move to left?
In game and graphics programming 0 will always be either top-left or bot-left but it will always be on the left. So it will make sense to move to right with positive numbers and move to left with negative. But why is it different on startScroll?
I´m just asking cause I´m really curios as to why designed it like this.
To illustrate what is going on, see the drawing:
The top drawings show the coordinate system: (0,0) is on the top left, and positive directions are right (x coordinate) and down (y coordinate).
The bottom illustrations show the effect of the scroll as it appears as the "view port" is moving.
On the left is the position before the call to scroll
On the right is the position after the call to scroll by x=+2, y=+3
The the light blue rectangle is the screen "view port": the scroll method is actually moving this rectangle (the representation of the screen), and not the content. See it like a camera you look on the world through.
The red dot is just an element positioned on the view, and it is not moving. Look at it as the world you look at.
You can see that moving the "view port" in positive x an y directions result on the red dot appear to be moving up and left. Just like you move a camera to the right will make the world in the video move left.
You are in fact scrolling the view to right, which result the content view to be scrolled to left.
Having |A|B|C|, now scrolling by positive value will result a scroll to right, which scroll the actual content to left: |B|C| - A is not visible anymore, because it is considered as a content and is scrolled to left.
We can imagine a scroll in two different ways. One is that the window is moving and the other is that the content is moving. According to the Android's documentation of getScrollX()
Return the scrolled left position of this view. This is the left edge of the displayed part of your view. You do not need to draw any pixels farther left, since those are outside of the frame of your view on screen.
it is clear that Android prefers the content respective scroll rather than window respective one. In content respective scrolls
Positive numbers will scroll the content to the left.
Not only startScroll(), other methods like View.scrollBy(), View.scrollTo(), etc. work with the same idea.
If you ask "which is more natural imagination, content respective or window respective?", I will say "I don't know".
Your Container View is fixed on your screen. When you scroll to right, the right items keeps flowing towards left. Thus, when you do
scroller.startScroll (int 2 /*startX */,
int startY,
int dx,
int dy,
int duration);
makes your content will scroll to the left.
Scroller is actually the horizontal or vertical side bar, which appear when there is a scrolling gesture. Think about movement in respect to scroller and observe it's behaviour in an app. You will understand why it's implement so. You are currently thinking in respect to touch position, causing the confusion.

Create a transparent expanding circle transition animation from one layout to another on swipe

When the user holds down on the screen, it should become transparent by their finger so that they can see the other layout beneath. When they continue holding down their finger and swipe, I'd like to create a transition where the transparency spreads outward from their initial holding location until the upper layout is gone and only the layout underneath is left.
Here are examples of the effect I'm looking to create:
I'm not concerned about the fancy movement of the purple / red squares; I'm just looking to find out how to create the swipe transition between the two layouts.
It seems like using android.R.anim.fade_in and android.R.anim.fade_out would get close to the desired effect but it would be missing the expanding circle centered on the user's finger and the transition would happen all at once instead of the intended effect of giving a peak when just held down and performing the transition only after a swipe.
you can use this npm
react-native-expanding-circle-transition
https://github.com/alexbrillant/react-native-expanding-circle-transition

SlidingUpPanelLayout with gravity=top wont snap in at bottom

The question is about com.sothree.slidinguppanel.SlidingUpPanelLayout.
I used the layout with the gravity=top to make the slidingPanel apear at the top of the main context.
But now the slidingPanel does not snap in, when it is moved to the bottom.
It immediately goes returns to the top.
It only snaps in when I drag it a little bit down and then release it.
Seems like the panel has an offset after which it snaps in, which is measured from the bottom.
Event if the slidingPanel is at the top.
Do someone know how to repair that?
The problem with the behaviour I described is with the min. velocity which is required to detect a fling.
Set DEFAULT_MIN_FLING_VELOCITY=0 to make the Sliding Panel expand, after user releases it on any height.

How to pinch zoom in/out and pan around in LinearLayout in android?

In my android app, I have a linearlayout where I put many linearlayouts with images in it. It will go past the screen border horizontally and vertically.
I want the user to pinch zoom in or out and pan around. I tried putting it in a horizontal scroll and vertical scroll, but it wont let me zoom, and I can only move in 1 direction at 1 time, like it wont let me move diagonally.
I tried this plugin
https://code.google.com/p/android-zoom-view/downloads/list
But it won't let me pan around. It only lets me do it on the stuff thats visible on the screen...
Does anyone know how to make this work?
Thanks
The easiest way I can think of is to put your images in HTML and use webview to display it.Webview automatically handles zooming and panning of content.

Categories

Resources