SlidingUpPanelLayout with gravity=top wont snap in at bottom - android

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.

Related

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

Moving, clickable, rectangle animation

I've searched and searched, but couldn't find what I was looking for...
There are many ways to animate in android and being a newbie I do not know which solution to choose for my app.
Here's what I want to do:
It's an animation of rectangles moving slowly (takes ~10 min to cross the screen) from top to bottom through the screen.
Each and every one of the rectangles is clickable, through some listener, and does something.
Two or three buttons at the bottom of the screen (which I already created as floating action buttons) do not move and float "on top", i.e. the moving rectangles pass underneath them as they move down the screen.
The animation can be stopped and then resumes by the action buttons mentioned above.
Newly appearing rectangles appear on top as they " emerge" slowly from the top of the screen, i.e. when part of them is still outside, as they reveal themself by moving down.
I want this to be simple and robust.
How should I implement this, and please explain why...
As a loop?
A separate thread? Of so how?
I would like to understand the rationale behind every approach...
Thanks,
Julius

Create "no more scroll possible" effect for HorizontalScrollView

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.

Moving imageview from top to bottom in android

I Have an ImageView in Center of my Screen, which i want to move up. where it remains at the Top.
I saw Tween Animation Documents and Tried it But Its Not Working.
Can any one Plz help me out solving this issue.
did you tried view animation?
Animation an = new TranslateAnimation(fromX,fromY,toX,toY);//0,0 is the current coordinates
an.setFillAfter(true);// to keep the state after animation is finished
yourView.startAnimation(an);// to start animation obviously
to make it move from bottom to top, get screen height and use it to set "toY" parameter.
after few tries you will sure do it.

Categories

Resources