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

Related

Change focus in RecyclerView in single vertical click

I am building an app for Android TV by using Nested RecyclerView. Root is vertical RecyclerView which has rows with Horizontal RecyclerView.
I want to change the focus on the single click and want to keep the scroll position static. But scrolling is always happening at the bottom of the view for horizontal and vertical both.
I am using the focus listener to scroll to top
verticalRLVLayout.scrollToPositionWithOffset(rowNumber,0);
horizantalRLVLayout.scrollToPositionWithOffset(columnNumber, 0);
This is not working always and i don't see this is the best option.
Is there any way by which if we have fixed height of each row the single click will change the focus always.
Going upward in the RecyclerView, causes new row to slide towards right and focus goes to last visible tile on the previous row. Why this is happening, any idea ?
Thanks

How to smoothly scroll to a position and make it appear at beginning in RecyclerView?

I have tried RecyclerView.smoothScrollToPosition(int position), but it's not what I want. It scrolls to a position so that the child get into the viewport; it can either appear at the beginning or the end. Moreover, if the view is already in the viewport, it won't do anything!
What I need to do is to scroll to a position and make it appear at very beginning of RecyclerView so as to arouse user's attention. How can I do with it?
You can use mRecyclerView.scrollToPosition(Position); to display the list item at top. However it will go to the specified position very quickly without any scrolling effect.

Scroll without Touch in Android

I want to give animation in GridView. So that when the list gets prepared, it will scroll to given position without touching the screen.
You can use the methods smoothScrollToPosition and smoothScrollToPositionFromTop to make the GridView go to that position.

how to scroll to a particular screen location without actually scrolling

I have a scrollview inside which I have 5 imageviews say IMV1,IMV2...IMV5 . Now on scrolling,one by one all imageviews are shown in device screen. Now I have a drawer with 5 buttons say 1,2 ..5.
Now take us a scenario,
Currently I am on first imageview. Now when I click on button 5 in the drawer.
I need IMV5 to show on the screen without scrolling.It can be obtained
through smoothScrollBy/scrollTo to y equal to 5*screenHeight. But here it
scrolls through all intermediate imageviews.
Please note,I don't wish to affect scroll feature.For above example,
After I reach IMV5,when I scroll up,it should scroll to IMV4 and so on.
Is there any way to obtain it .Please suggest.
Thanks In Advance.
P.S. If you need some more clarification,please let me know.
You can achieve this easily using a ListView instead of ScrollView.
What you can do is:-
Add all the imageviews to a ListView.
This will fulfill your scrolling requirement, as ListView automatically handles scrolling if its content's size is grater than the screen size.
Now use the listView.setSelection(position) on click of the buttons.
It will scroll to the selected imageview without giving the scrolling effect
Hope this helps.
It can be achieved through ScrollView too.. All you need to do is get the View at that position. Then call requestFocus() on the obtained view.
For example:- If you press Button 5, then IMV5.requestFocus() will do it for you

Is it possible to auto scroll In 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.

Categories

Resources