This is my first post on stackoverflow. I use this one some times when I have a problem and find a solution every time. But today is different. Have a non-solved problem :
I have on listview and I want apply a magnetic effect on this. To make this, I use scrollBy one by one pixel with Thread to move listview position. Visually, it's perfect, listview move good. But when user want scroll again, listview come back to his previous position (just before scrollBy) before scroll normally with user finger.
I've tried some tests, for exemple I display v.getTop() (v is on view item in listview) value BEFORE my scrollBy and AFTER. Values are same, but visually are really different because list are moved. Also visually, you can see a little artefact : this divider is ON listview item. It's means that visually, listview is good, but programatically isn't good... while scrollBy make invalidate estate.
Anyone have an idea or a solution ?
Thnak you for your help.
PS : Sorry for my english, i'm french. Thank you again.
Use getScrollY() to find the current position and then set that position after it gets reset.
Related
Wanna implement the filling of my ListView with the effect like that: the first item rotates X and fades in, later the second one and so on.
One way to do it is clear - add items one by one to the adapter (just like in that post), while the animations are handled by LayoutTransition object, which I set in advance.
However, I have a strange feeling, like it'd be somewhat a crutch to add items asycnchoniously just in sake of animation effect. Does anybody know how to do it better?
UPD:
Some details: I want items to be animated only when the underlying data changes, for instance, the server sends new info and the list updates, just like the old departure boards in airports.
Use a LayoutAnimationController....
LayoutAnimationController lac = new LayoutAnimationController(AnimationUtils.loadAnimation(getActivity(), R.anim.table_row_appear), 0.5f); //0.5f == time between appearance of listview items.
listView.setLayoutAnimation(lac);
Whenever you want to run the animation :
listView.startLayoutAnimation();
Finally, I ended up with using the LinearLayout instead of ListView because of the view reusage, that reruns the animation for every view whenever it's showed up again.
But I did it just because I didn't have too many items to show. Another approach, as I guess, is to load animations in adapter, compute delay in accordance with item position and to store the map with the info, wether the view has already been animated in or not.
You can create an animation(transition + fade or any other effect you want) and add the animation to the Layout (view) that you return in "getView"
the animation shall take in consideration the "position" parameter to create the delay when the animation is started.
enjoy
daniel
When I remove an item from a gridview, it fades out (because I start an animation) and all the other items change their place "at once".
Is there a simple way to animate all the other items to move, so the empty spot get filled up nicely animated, and not "at once"?
I would like to do the same for adding a new Item: all existing items will move animated and make a free place at the start of the grid where the new item will appear. I could of course do this by animating every item on itself, doing something different for the items at the end of a line, etc. But I would think there is already something prepared for this?
I checked out http://developer.android.com/reference/android/view/animation/GridLayoutAnimationController.html
But that only seems to be useful for showing the grid come into view, not when it already is in view.
Also, if you know an open source program that implemented this, please let me know.
This helped me a lot, you can at least use the animations in this project, but maybe the whole thing will suit you:
https://github.com/mrKlar/PagedDragDropGrid
example on youtube here:
http://www.youtube.com/watch?v=FYTSRfthSuQ
It looks like a gridview but isn't a gridview object. I used some of the code to change my own (android) gridview, but that was a great deal of work. If you can, just use this whole project.
I want to create a horizontal listview which contain many item, one item will contain a image. When user slide listview => the count of item will be fix when it display, example display only 3 or 4 image. How can I do that? Many thanks.
Edit:
I use this
to create a HorizontalList view, everything is ok but I don;t know how to make the Next and Previous button work! Any idea?
Instead of a horizontal ListView (which, as far as I know, isn't offered by the Android SDK) you can use a HorizontalScrollView. You can add the items like to any other kind of layout class.
It looks like what you are looking for is a Paginated Gallery. I have written one here.
Its still only a couple of days old but hopefully the included Activity code will get you off the ground.
I have a HorizontalScrollView that shows three dates at once and snaps to the date in the middle when you lift your finger. Currently the dates are saved in an LinkedList.
The list has to be dynamic, means that when I scroll to the right, it has to reload the next dates on the right and delete some of the dates on the left. The problem is, I don't know how to create a link between my LinkedList and the ScrollView.
Here is a link to how it looks
Its my first post, so please excuse me if I'm not specific enough.
EDIT: Okay, I found the answer: Gallery offers exactly what I want.
As I said in the OP: Gallery in combination with a custom Adapter solved my Problem.
My Query is in my ListView let say if I scroll to 1st position that is fine but now my ListView scrolls beyond that also like my fisrt item will also go down and there is no item before first item so blank screen comes which is looking very bad i hope, i have described well can anybody look into this.
I have seen this issue in Galaxy S while over other devices this behaviour is not followed. So I think some device manufacturers have modified their OS and we can't do anything in this case.