Repeat bottom elements for top-overscroll in Android ListView - android

I have a simple ListView in my Android application that gets its data from a custom ArrayAdapter.
When you scroll up to the top and try to scroll further (same for bottom), there's the overscroll that is shown to the user with the bounce effect.
However, I would like to change my ListView in so far that, if you scroll over the top, the ListView will display the elements from the bottom (in reverse order) again. Is this possible without re-implementing the complete ListView or ArrayAdapter?
What modifications are necessary?

I think it is pretty easy to do this. You don't have to re-invent listview. You can derive from BaseAdapter and just return a very high number for getCount, let's say 1 million. Have the initial scroll position start at item half million. Then in getView just mod the request position by the actual count of items you have.

Related

How to implement custom listview with "stacking" feature Android

I want to create a custom listview that scroll horizontally and stacks the last 4 items in the view instead of allowing them to go off screen. The stack should look something like this: . So if a user scrolls all the way to the left they see a regular listview, but as they scroll right, if an item was supposed to go off screen, it is instead stacked behind the last item in the list, with a max of 4 stacks. What's a good basic way to accomplish this? I already found the horizontally scrolling listview library I wanted to use but don't know where to start on the stacking part.

Android: ListFragment, how to show only one list item on whole screen

how can I set ListFragment to show each of its items on whole screen? And of course, when you swipe up and down, whole item should be available at a time, the list shouldn't stop scrolling in the middle of two items. Thanks for any suggestions.
You have two choices:
Add a OnScorllListener and implement logic to "settle" the list
after a scroll.
Make a vertical ViewPager. You could copy the source code and flip everything from using X to using Y.

Drag and drop in listView: drop over a listItem so as to combine them rather than sorting

I want an expandable list in which I can drag a child item and drop it over some other parent list item which will result in child moving from one parent to other. I only need a direction how we can achieve this in general listview (let alone exapandable). Examples are available for picking up a listitem to change the order of listview i.e. to sort that list. How can I accomplish dropping over a view in order to group them.
Your best bet will be putting your effort on customizing and making your own listview, Consider extending AdapterView, this will give you more power over controlling child display and organizations, Putting animation such and drag and drop will be easier for you in this case, Otherwise with simple list view it might work but i doubt if it would generate the required result you want.
Here is a link for exending AdapterView and customizations, go through it it will give you enough confidance to put in your animation. I tried almost similar stuff and was succesfull by same way, unfortunately I dont have implemented code with me.
http://developer.sonymobile.com/2010/05/20/android-tutorial-making-your-own-3d-list-part-1/
Else with list view try doing following,
Your listview should be wrapped inside a framelayout, you will need layers
Enable drawing cache for childrens, coz animation you seek requires playing with bitmaps
Second, when you touch a child in listview, get the bitmap of child, and inflate it at same coordinates of touched child, you can get position of Child easily.
Now time for some animation, you enable drag and drop over inflated bitmap, now when you move it, first thing you need to do is, shifting all the childrens in list view either Up or Down depending upon movement of finger, you can define somekind of threshold like unless half the height of children is moved you wont shift childs in listview up or down.
Moving child will be easy, all you need to do is applying Transformation animation to all the currently visible child in listview, use childCount and ChildAt api for the same, and animation set for playing them together.
Thats it when you build space by shifting child, user will feel like drag drop and shift, all the thing you need, when user places it a place, just modify your dataset underneath listview reposition it based on recent changes by user and refresh it,so that listview reorders itself.

Android Listview Cell Overflow Past Extents

I am trying to have a listview cell slide up to partially cover the cell above it. Is there a way to allow content from one cell in a listview to overlap content in another listview cell?
I assume I would use a TranslateAnimation to slide up the top view to reveal the subview, but how to slide over another cell is where I am lost. Is this even possible?
I'm not sure, but you can retrieve your cell like this:
getListView().getChildAt(index);
when index means the position (starting from 0 I guess).
Do the TranslateAnimation and then if you want to make the above cell disappear, just delete it from your list's items array and look for a "refresh list view" method or something alike.
I've never tried it. Try and comment with results.
Good luck!

Need help animating an Android ListView

I have a ListView in my Android application. The individual views in the list are a little bit smaller than the size of the screen.
I want the list to always show one item centered in the screen, with just a small sliver of the previous and next items showing above and below it.
When the user scrolls, I need to reposition the child view at position 0 or 1 (depending on which way they are scrolling). Currently I am doing this by calling "setSelectionFromTop" in my onScrollStateChanged method. This works, but the transition is immediate, not smooth. It is jarring and confusing in a lot of cases.
What's the best approach to fixing this? I want to animate the process of scrolling the list into the position I want, but I can't find any methods in ListView or its superclasses that let me directly control the scroll position of the entire list.
I think I could animate it using multiple calls to setSelectionFromTop(int position, int y) with progressive values of y, but I don't know how to determine the initial value of y. Is there some way to get that by interrogating the view object at the designated position?
Another challenge I have in front of me is that I want to animate the removal of an item from the list - by having it either disappear or slide away to the left, and then having the surrounding views move up and down to fill the space. Is there a straightforward and reliable way to do this with a ListView? Should I just give up on the ListView and write the whole thing as a custom view from scratch?
Thanks.
This definitely should be possible. Does smoothScrollToPosition() work?
Otherwise, you can try simulating the touches using TouchUtils.

Categories

Resources