How to set a final scroll's position in listView? - android

Maybe someone faced such a problem: I have adapter class, customView class. Everything works normal. But: When I scroll listView, It's possible to stop the scroll anywhere in the middle.
But I expected: a final scroll's position (when soon as user's finger is up and inertia-movement is completed) should always be like on my screenshot(image1) and never like this(image2).

I hope I understood your question right.
To achieve this in ListView Android ListView - stop scrolling at 'whole' row position
For RecyclerView You can achieve this by using SnapHelper
LinearSnapHelper().attachToRecyclerView(recyclerView)

Related

Animating ListView sliding down

Trying to animate a search bar result, which is a listView contained in a FrameLayout. Basically, all it needs to do is when the search button is pressed, the listView drops down along with the ListItems populated by a listAdapter. Right now, I cannot find a way to animate this outside of the adapter's getView method. However, if I animate the adapter's getView method, this animation would animate every single time the listView changes, which is not desired in my case.
The list populates after nofityDataSetChanged is called, so how would I be able to know the size of the listView before it's fully populated? or what exactly is the right way of doing this.
I just need it to animate on the first time. Therefore, the question is is there a more elegant way of animating ListView without changing anything in the ListViewAdapters.
Thanks for the help!

Underscroll in RecyclerView android

I am creating a custom scroll inside RecyclerView and I did most of the work already but now I came to hopefully one of the last problems.
On scrolling, I am expanding/collapsing rows as they move up or down. It works fine until I reach the bottom of the list. Two items remain in their normal state because I can no longer scroll down and therefore they will not expand.
My question is, how can I scroll under the recyclerView when I reach the bottom? Do I need to implement onTouch listener and do the work from there? Or is there something in RecyclerView that can help me create the underscroll?
You should be able to expand them in onOverScrolled, as that will be called at the correct time to trigger their expansion.

Animate RecyclerView onLoad

I have been looking for a long time for a Android RecyclerView onLoad animation
but until now I have not found anything really helpful.
What I want is to have an animation when the RecyclerView loads and displays the cells animated.
But I want to have that animation just when the RecyclerView loads and not when the cells are loaded by the ViewHolder.
Because when the cells are loaded by the ViewHolder the RecyclerView animates the cells while scrolling and so on...
So I don't want no animation while scrolling anymore.
And some guys will know that the effect I would like to implement is
a standard animation effect the TableView of iOS supports.
I have found a tutorial where is exactly done what I would like to do.
The last example is what I mean.
So all solutions I have found were similar to that one
Has anyone an idea?
Or is the way I would like to animate the cells "not Android standard like"?
kind regards
Well one way to do this is to make sure that you are animating the entire recyclerview when your activity / fragment is ready and displayed on screen. So instead of animating each individual item in the recyclerview, you set an animation on the recyclerview as a whole to "fly" in for example, by animating the TranslateY element of the recyclerview.

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

Android Scroll ListViewfrom code

I'm trying to have a piece of code cause a ListViewto scroll. This is happening as another view is being scrolled. Currently I'm calling scrollBy(x,y) on this ListView to cause it to scroll. This causes the items in the list to scroll but does not cause new items to be loaded. I've tried calling invalidate on the list but this does not seem to work. The problem appears to be that what the list understands as visible items are only updated by touch events.
Does anyone know a way to get around this?
I think the problem is that ScrollBy and ScrollTo are methods of the base View, and thus seems to be scrolling the whole 'viewport' of the list.
If you want to scroll the items use smoothScrollBy or smoothScrollToPosition.
That should work

Categories

Resources