I want to create a kind of scroll view that its elements are fixed in the middle of the view and the user needs to move the element a considerable amount or the view bounces back to the middle of the view.
I tried to use several overscrolls next to each other and create a bounce effect but the result wasn't pretty.
is there any library for this kind of scroll view? or there is any way to do this?
If I understand this correctly, you have a fixed element fixed in the middle of the viewport. You want the user to move the element some fixed amount, say X.
If moved less than X, it should go back to the middle of the viewport?
If yes, then you should definitely look into http://bouncejs.com.
Also, this might interest/help you: https://scrollmagic.io/examples/
Related
Could anyone please explain what MotionLayout's onSwipe parameters touchAnchorId and touchAnchorSide do? This is what documentation says about touchAnchorId
View that is being moved by the swipe.
That doesn't make sense to me as swiping on MotionLayout doesn't move a single view. Swiping progresses transition between starting constraintSet and ending constraintSet. I thought initially that touchAnchorId would specify a view that user will have to drag to progress animation but this isn't a case and MotionLayout developer team introduced touchRegionId parameter for that. It's also unclear to me what touchAnchorSide is supposed to do as I don't see any difference when changing its value.
onSwipe Move progress from 0 to 1 along a
direction(dragDirection=) horizontal (dragRight/Left/StartEnd) or vertical (dragUp/Down)
If I drag my finger a 100 pixels along the screen how much does it move from 0 to 1?
That is the main question most of the other argument answer.
with out an anchor it uses the full length of the layout.
But if you are making a pull out draw that is excessive.
You could adjust it with dragScale. But how much? The pull may vary based on constraints fonts many things.
Many times you want it to act as if you are pulling a view or a side of a view. In which case you ned to the View (touchAnchorId) and the side of the view (touchAnchorSide)
Sometimes you want to limit the region in which the swipe will work
In which case you can use limitBoundsTo.
Much of the rest of the flags are bout what to do when you lift your finger.
There is much more subtly in all the use-cases it is designed to support.
I am rotating my View using SetRotationX. However, since this is a scroll view, I want the rotation to always be performed on the visible part of the screen (the middle of it). The default behavior is to rotate it around the middle of the view, which sometimes is out of screen.
I've noticed the "transformPivotX" property, but I'm creating my view on the fly, not from the resources.
Does anyone know how to do it (programmatically)?
Thanks,
yakobom
OK, that was stupid... I dont know how I missed it. It's "SetPivotX"...
I want to create the following view / set of views which behave following way:
I have huge set of points which have been stored to DB in web server.
My client application downloads those and should draw curved lines about the data.
What components should I use here to get this "infinite" scrolling view to draw content dynamically.
No snapping wanted, so it should be smooth and can stop to every X position.
Should I proceed with this by using HorizontalScrollView with horizontal LinearLayout and remove/add views based on scrolling, then translate the scrolling position and provide fling that the scrolling doesn't stop suddenly.
Or is just one canvas possible to use and draw the content to simulate the scrolling?
Maybe a horizontally scrolling ListView component?
The solution should be efficient and use minimum of memory.
Which solution do you recommend, or do you have some new ideas other than above?
All suggestions are highly appreciated. Thanks.
There is several possibilities:
Create custom View class and implement GestureDetector there. You can get movement of finger, calculate currently visible area and draw only visible part of content.
May be this solution is not the easiest to implement, but it will be fast and does not require any resources.
I have a TextView with an arbitrary amount of text. My goal is to have it automatically scroll from completely past the bottom of the view, all the way through, and completely off the top at a fixed rate independent of the text length. I currently have something mostly working with a linear Scroller, but it's a huge mess. The Scroller only works in terms of a scrolling range at a fixed duration, so I'm having to calculate that based on how many lines are in the TextView, the line height, and how many lines per second I want to scroll.
Consequently I can't do anything until after the view finishes sizing itself, pausing and resuming the scroll is a mess, etc. The code just looks terrible and I'm wondering if there's a simpler way to achieve this effect without jumping through hoops and very likely introducing unforeseen bugs?
Thanks!
I have written a custom View which is used to display a tileable pattern, and want the user to be able to zoom in (which I've got covered) and then move around within the pattern.
Because the pattern is tileable it means that there are effectively no bounds on it. In theory a user could just keep scrolling left (right, up, or down) forever. In reality I would be using a modulus to adjust the virtual position.
I'm just not sure where to start. Would I use something with scrollbars? I'm not sure that makes any sense, because as I said the viewable area is effectively infinite.
Thanks for any suggestions!
I'd use a scrollview with the scrollbars turned off.
android:scrollbars="none"
I decided a scrollview was unnecessary. All I really had to do was handle the touch events and then adjust the virtual coordinates accordingly.