Android Listview Cell Overflow Past Extents - android

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!

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.

Center aligned selection with animation in ListView (?)

I need a component that works like the picture below but I'm having trouble coming up with some kind of decent solution that works.
I want the list to have a center locked selection but being scrollable with the d-pad. This is for an application running on a TV so no need for touch scroll. So when pressing down on the remote d-pad the list will scroll and a new item will size up and the current selected one will size down and the new selection will still be in the middle.
I've tried doing this using a ListView that I extended and programmatically scrolling when pressing down or up. On scroll finished I called notifyDatasetChanged() on the ListView for re-inflating of the childs and in the ListViews adapters getView() I made the animation of the view located at the current selected position.
This is not optimal since I need to call notifyDatasetChanged(), which re-inflates all visible views, for the animation to apply. The UI becomes laggy when doing this and scrolling fast. It's also not possible to make som kind of compress animation when current selected item goes out of selection. There is also some trouble with the end items (read views) such the first or last in the list when doing animation of them, the may sometimes go out of screen.
I think that his must have been done before and maybe I'm missing it when searching for an answer.
Have anyone done something similar or do you have some suggestions of how this can be achieved? Maybe I'm just starting of with the wrong component here..
Regards,
Kristoffer

Repeat bottom elements for top-overscroll in Android ListView

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.

How to create a gridview with spacing at the top

I was looking to create a GridView that stretches across the entire screen. However, when the user first opens the screen, the top of the first item should be about halfway up the screen.
For example lets say we have a GridView of 12 items displayed 3 x 4. When the user first opens the screen, only the first six items would be seen with a large margin at the top of the screen. The user can then scroll the list to see the other items. The top items would eventually reach all the way to the top of the screen.
If I was using a ListView, this is simple. I merely create a 0dp headerView with a large top margin. But, GridViews do not allow for headers. What is the best way to handle this situation?
Normally, you DO NOT make a GridView inside a ScrollView. It's not recommended! But sometimes you have no choice and you need to addHeaderView() on a GridView (But I repeat, it isnt recommended).
So, to make this happen, you have to make a custom GridView. This answer will be usefull in your case: Grid of images inside ScrollView
I had a same situation and I used this one: HFGridView by #SergeyBurish! Very simple and really great. (See the last answer here: A GridView with header and footer).
Hope this will be helpful.

animate adding item and item movement in listview

How can I animate adding new item or moving item from one position to another in listview? I want to make animation effect, like in this app: any.do(youtube). I'm using adapter extended from ResourceCursorAdapter. How I should use newView and bindView functions to achieve this effect? Or is there another way to do it, like extending ListView class? I suspect that there is a ScrollView instead of Listview in any.do app. But I think this is wrong way, if you will have many items in list. Any ideas?
To do that effect, you need to:
1. "close" the slot where the item used to be.
2. "open" a slot in the list, where the item will "land".
3. Move the item between the slots.
To achieve the first animation, you need to animate the list item view itself. To make it disappear, you can animate the value of its bottom margin. I wrote a blog post about other Animation I did in Any.DO, where I animated this value - http://udinic.wordpress.com/2011/09/03/expanding-listview-items/. You can use the same animation to animate list item's view.
The "open" animation is the same as the close, but in the opposite direction. You take the list item, positioned right before your "landing point", and animate its bottom margin outwards, making an empty space for the new item to come.
Moving the item between the positions is fairly easy. You need to inflate a view with the same layout as the list items, populate it with the current item's data, add it to the WindowManager:
WindowManager winManager = (WindowManager) Context.getSystemService(Context.WINDOW_SERVICE);
winManager.addView(..)
and animate it's coordinates by using:
winManager.updateViewLayout(..);
After the animation will finish - you can remove this view and refresh the list.
The Add item animation is done using the same concept.
Sorry I don't have full source to provide here. At my blog post you can find the code for the expand/close animation.
Hope this helps!

Categories

Resources