Xamarin.Android HorizontalScrollView, How to disable release momentum? - android

By default when I scroll the contents of scroll view and take off my finger the contents keep scrolling for a while after then stops. I want to know if there is a way to stop scrollview from keeping going after I take off my finger?
I'm using xamarin.android, tried Disable "flinging" in android ScrollView? solution but didn't work.

Related

How do I cause vertical two-finger swipe behavior to cause a horizontal slider to move left or right?

I have a horizontal slider in my app, and I want to make it so that if you have the slider selected, you can do the two-fingered swipe up or down gesture from anywhere on the screen (The scroll up or down gesture) to move the slider left or right. I haven't been able to find anything through google about how to change vertical swipe behavior for Talkback and was wondering if there was in fact a way to change this.
I'd really suggest not doing this, it isn't how Android works so it will confuse your users, and be a big source of bugs as any behavior like this can cause touch errors on completely separate views. I just fixed a problem on something similar in my company's app.
But if you really want to do this- your root ViewGroup needs to intercept touch events if there are two fingers down and it moves far enough to qualify. Read https://developer.android.com/training/gestures/viewgroup#intercept for an explanation of how a parent view group can steal touch events from the child. This is the same way ScrollView works to scroll its contents. In fact, looking up the AOSP implementation of ScrollView would give you good example code.

How can I disable ScrollView scrolling if it's not needed?

My UI consists of a ScrollView that takes the top 50% of the screen and under that two buttons that are attached to the bottom of the screen; YES and NO. The content of Scrollview is text that for most phones does not fill up the visual area of the ScrollView. However sometimes the text can be longer, such that it fills beyond the visual area of the ScrollView, hence the reason I added the ScrollView.
My problem is this; even when the ScrollView has very little text and does not need to scroll to show all of its content it still scrolls. The user can scroll the content up a slight amount. I'd like the View to instead not allow any scrolling if all the content is visible.
Is there an easy way to achieve this? Or do I have to implement that myself?
You cannot disable the scrolling of a ScrollView. You would need to extend to ScrollView and override the onTouchEvent method to return false when some condition is matched. To get help with extending, please read the answers to Disable ScrollView Programmatically?

How to hook into Android ScrollView when it starts/ends scrolling?

How do I programmatically hook into an Android ScrollView when it starts/ends scrolling? I have a custom View which is placed inside a ScrollView. I want my custom View to be informed right before the scrolling begins and just after the scrolling ends to execute some arbitrary code.
Note: I'm coming from iOS development and basically I'm looking for the Android equivalent of UIScrollViewDelegate.
For achieveing this, you need to create a Custom scrollview by inheriting from scrollview.
Check below link. It will help you :
Synchronise ScrollView scroll positions - android
Android: Detect when ScrollView stops scrolling

Scrolling in viewflipper

This is one of the intermediate screens in the app.
I'm using a viewflipper.
I'm setting this view using vf.setDisplayedChild(9); where vf is ViewFlipper object.
Referring to above screen-shot, if I reach upto country field (which I'm checking through isFocused()), the whole view should scroll by some pixels (equal to keyboard height).
If I hadn't used viewflipper, then I would have tried something like scrollTo(x, y).
But how do I scroll in viewflipper.
Any help appreciated.
You could place a ScrollView as the view inside of the ViewFlipper.
The only problem I think you may still run into is that the keyboard should automatically shift things up (in my experience it doesn't function properly while in fullscreen though). I'd try displaying that screen without the fullscreen enabled and you may find that your behavior is handled automatically.

Android: Detect when ScrollView has finished scrolling and bouncing back?

I have a ScrollView which has two hidden images, one at the top and one at the bottom. In between there is a bunch of visible content.
What I need to do is make these images hidden by default but when you scroll all the way up or all the way down you could see them as you're scrolling. But then as soon as you stop scrolling it should bounce back to the visible area so that the hidden images aren't showing.
Basically I'm trying to imitate the bounce scrolling feature of the iphone UIScrollView.
I have my ScrollView all setup and I do a scroll at the beginning so as to hide the top hidden image. Now all I need to do is detect when a scrolling has ended, figure out the Y position, and check whether a hidden image is shown. If it is, I would just programmatically scroll the view back so that the hidden image is hidden.
I hope all that made sense.
So anyways, I know how to programmatically scroll a ScrollView. Now what I need is some sort of callback to tell me when a ScrollView ended scrolling and also a way to get the ScrollView's current 'Y' position. Are there any such methods I could use?
I looked through the ScrollView docs but nothing jumped out at me. I'm still not very familiar with the Android naming schemes so maybe I missed something obvious somewhere.
Anyways, any help would be appreciated here. Cheers.
You can use an OnTouchListener to detect when the user presses/releases the list.
You can also use the onScrollStateChanged method of the OnScrollListener class (most likely in conjunction with a touch listener) to detect changes in the SCROLL_STATE - when the list has stopped scrolling the state will change from a state that is not SCROLL_STATE_IDLE to SCROLL_STATE_IDLE.
Alternatively if you are using 2.3 or above you can use an OverScroller to get the desired effect (see Modifying Android OverScroll for how to change the over scroll effect to an iPhone like one).

Categories

Resources