I have a scrollview and its vertical scrollbar. If I touch anything within the scrollview and drag, it will scroll the view the opposite direction I dragged. This is the behaviour I need.
If I on the other hand grab the scrollbar and drag it, it will not be in the opposite direction, but in the same direction as I dragged. I could simply hide the scrollbar, but it gives the user a sense of how much content the scrollview contains.
TL;DR
How do I disable touch events on scrollview's scrollbar?
Related
I'm trying to implement a feature using motion layout. In that I have created a motion scene which scrolls from bottom to top and vice versa. After the view goes to the top a recyclerview will be show below to the motion layout.
Issue: While scrolling the recyclerview from top to bottom it's automatically drags the motion scene as well with the velocity applied in the recyclerview. But my objective is to not drag the motion layout as shown in the attachment.
Expected behaviour: After the recyclerview's scroll velocity reaches the top. The velocity has to be cancelled. Again, If the recyclerview is scrolled from top to bottom the motion layout should drag to the bottom based on the user's velocity.
source code
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.
Problem statement: I would like the canvas to have the same size in both horizontal and vertical orientation. The size should be fixed and based on the vertical orientation (an A4-like canvas). Hence, I need the ability to scroll over the canvas in the horizontal orientation. But there is a conflict between the touch event used for scrolling in a ScrollView and the one used for drawing in the canvas.
What I need: I guess most could settle with this solution: fingerpaint within a horizontalscrollview and simply adding a button for allowing the user to scroll. For me this is a little counter-intuitive. What I would like is to have a thick scrollbar constantly visible on the side of the canvas, like in this app:
Following, this should also be the only way that the user can scroll.
What I have tried: Since the scrollview consumes all the touch events, I have tried overriding the scrollview's onTouch method. But this leads to the whole scrollview being unable to be touched - that includes the scrollbar.
Questions: Is it not possible to implement this with a ScrollView? Do I have to create my own scrollbar widget and align it horizontally (LinearLayout) with the view that contains the canvas? Or is there some way to have the ScrollView only consume touches on the background?
In onTouch override, you can check the coordinates and decide whether the touch was on the scroll thumb or on rest of the view.
I have a custom component that is vertically longer than the screen height and I'm trying to make it scroll. In my onDraw method, I'm drawing the shapes unto a fixed coordinates, and it seems that the content doesn't change even when I scroll. Do I need to draw the shapes unto a different coordinates based on the scrolled position? If so, how do I retrieve the current scroll position?
If you don't want to handle any scrolling from your end, then add your customView to ScrollView. If you want to handle the scroll from your end then you can refer to thebelow link which is for 2Dscroll which handles both Horizontal and Vertical Scrolls.
Android Two-Dimensional ScrollView
What is the best way to make scrollviews move dependent of each other?
I have three scrollers (ScrollView/HorizontalScrollView), on vertical on the left and one horizontal on te top - e.g. like excel - where moving the left or center scroller should affect vertical scrolling in both and moving top or center should affect horizontal scrolling in both.
What is the best way to implement this?