Is it possible to auto scroll In Android? - android

It is possible auto scroll in android? I want my layout to start scrolling when my user loads up the screen, is it possible to do without them having to touch the screen?

I don't think, there is a default method to solve this. However the ScrollView class (you probably need a ScrollView, to make the content scrollable) has a method, which enables you to scroll smooth through the content:
smoothScrollBy(int,int)
the first (x) value is the horizontal, and the second (y) value is the vertical scroll. You could use a background Thread to call this method with the desired parameters, until the end of your ScrollView is reached.

Related

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 find scrollview scrolled position dynamically in Android?

Hi,I am new to android.my requirement is when user scrolling the scroll view,based on scrolled height i want to change images on screen. for this i want the event which will call immediately when scroll is changing,and once user reach end position i want set it to first position programatically. it is continuous loop.
You may use the listView instead of scrollView. So you can use onScrollChangeListener.

How to control the LinearLayout In the ScrollView In Android Eclipse?

Hi there I am in the middle of developing my app and am just curious to find out whether or not this is possible.
Ok so I have loads of text in my Layout and I want to pragmatically control where the linear layout in the scroll view has been pressed.
For example I want to program my app to go in the middle of my text how would I do that?
What about using the "scrollTo" function. Programatically you will be able to specify the x and y to scroll to.
http://developer.android.com/reference/android/widget/ScrollView.html#scrollTo(int, int)
Here is an example of how to use the scrollBy and scrollTo methods. Essentially you give it an offset in pixels for the amount you want to scroll. You can use getScrollX and getScrollY to get positions, though it sounds in your case you might want to use "scrollBy" to scroll an offset based on the top of the scroll view and where the user pressed.
http://android-er.blogspot.com/2011/09/scroll-view-scrollby-and-scrollto.html

Android: How to change ListView's scrolling trigger "sensibility"?

When vertically sliding finger on a ListView, it starts to scroll after a small move.
Is there any way to increase this "gap", so it would be necessary a "larger" move to trigger the ListView's scrolling?
There's nothing explicit like setSensitivity but you might be able to set a flag to detect when the ListView isn't scrolling. So then onScroll if the flag is set to true, (meaning that it has started scrolling from a fixed position), set the flag to false, and in the override of the scroll method only allow it to scroll once the amount is over 10dip for example...
Then when it stops scrolling again, set the flag back to true.
It's just an abstract idea but it sounds like it could work.

Vertical smooth scrolling of values in a text view

I have a text view where in i have to keep ages between 1-99. I also have two buttons ^ and v(i mean up and down arrows) on clicking them the values of the age should smoothly scroll to next or previous value.
I have been trying different ways but couldnt achieve smooth scrolling. Can anyone please give me any idea of how to achieve the task.
I think the easiest way is to simply put the TextView within a ScrollView, and let the arrows interact with the ScrollView, by using things like the fling method and playing around with the velocity parameter to suit your needs.
Use the animation framework.
When pressing down, start the 'down'-animation.
When pressing up, start the 'up'-animation.
Read more about animation here: http://developerlife.com/tutorials/?p=343
View animation is not much matured and hence i am noy sure if that can be used for moving the views.
Please find the description below:
Another disadvantage of the view
animation system is that it only
modified where the View was drawn, and
not the actual View itself. For
instance, if you animated a button to
move across the screen, the button
draws correctly, but the actual
location where you can click the
button does not change, so you have to
implement your own logic to handle
this.
Source
To scroll smoothly you can try using the scroller component.
Reference
What you would need to do is pass the duration of the scroll in the constructor and then use the property
setFinalY(int newY)
to increment the counter position by 1 unit (equal to the height of the item).
Please let me know if that helps!

Categories

Resources