Reputation: 216
So basically i have a an imageview inside a scrollview, what i want to do is be to be able to scroll infinitely without ever reaching the bottom of the scrollview. Can this be done in any way ? the image of course will have to be repeated .. but any other method is appreciated
Upvotes: 0
Views: 145
Reputation: 5591
You can use a ListView
and an Adapter
that is modified slightly to have "infinite" scroll.The change required in your Adapter
is something like this:
@Override
public int getCount()
{
return Integer.MAX_VALUE;
}
The trick here is to tell it that the count is MAX_INT
.However by doing this, it will make scroll downwards infinitely but not backwards.
In order to make the list go backwards, as in an infinite carrousel, you can trick the system by setting the default element to be something like Integer.MAX_VALUE/2
by calling:
listView.setSelection( Integer.MAX_VALUE/2 );
By doing this, it makes the effect of infinite carrousel in both directions.I think presence of ImageView
will not be a problem and it should work then too.Hope this helps.
Edit
For this, as you need to learn how to make a custom ListView
and a Adatper
, i suggest you to follow this easy and short tutorial.You can also download the entire project from that link.After running that project, add the above mentioned code.
Upvotes: 1