I am animating views between two RecyclerView. The first one is something like a list of folders showing the first item as cover, clicking it opens a new view showing the folders content animating the cover to the first item. Clicking back animates all visible views back to the folder where they came from (the cover being the top most view). This looks great as long as the opened folder shows the first item. If I scroll down the first item will be offscreen and the back animation does not look that good anymore because the cover view is not animated (I'm only animating all visible views currently).
What I think would work is following: the LayoutManager could position the first item at a position shortly offscreen and keeps it as a special view in it's pool so that u always can access the first view and when I animate back to the folder view I can animate the cover in addition to all other currently visible items ( the cover will be animated from top of the screen).
This means I need following:
the LayoutManager must handle the first item as a special one that is not recycled (I may need it any time for the back animation)
the first item must always be layed out (either at the default position in the list, if it is visible or offscreen directly above the screen), again because I may need it at any time for the back animation
Can someone help me where to start here? I think this is possible with extending the LayoutManager but I don't know where to start...
Have you tried the following?
recView.getRecycledViewPool().setMaxRecycledViews(TYPE_XXXX, 0);
Related
I initially used this method: myListView.setScrollingCacheEnabled(false); to enhance my list view's scrolling performance. However, I feel like it is causing a small bug in my list view. And I am not sure what it actually does.
1 out of every 20 times I navigate to the activity or fragment that contains the list view. The list view is not visible, then when I touch the screen, it immediately appears.
What is the difference between myListView.setScrollingCacheEnabled(false); and myListView.setScrollingCacheEnabled(true); ?
I have stumbled upon a problem regarding the RecyclerView. The situation is as follows:
I navigate from one Activity to another, the second one having a RecyclerView
The second activity reads an index out of the Intent and jumps its RecyclerView to that position (so it may "start" in the middle, from the user perspective)
The RecyclerView houses a list of news, each one having a network-obtained thumbnail
The thumbnails are obtained using Glide, with a placeholder (so a View inside a ViewHolder is at first inflated with height X, which may change after the thumbnail is obtained)
Now the problem is that when the user scrolls up from the item they started up, the ViewHolder is created and Glide makes a request for a thumbnail. It results in the list item having some height and changing it a second later, after the thumbnail is obtained, which in turn results in a nasty "jump" (because of the size change). It only happens 3-4 times, until enough ViewHolders get created to handle the whole RecyclerView.
Any idea how to prevent this? Ideally I would like to make the item above current to expand upwards.
I already tried making the items stack from the bottom, but it does not solve the issue, just makes it happen for the below items instead of the above ones. Also, I can not and don't want to predict the size of the obtained thumbnail.
I would use a place holder image in the Recycled View. And replace that image when it becomes available (downloaded).
This only works of course if you know the size of the tumbnails.
I'm trying to do a recycler view animation on scroll, but im struggling to get it started.
Basically, the animation will happen on scroll and always on the first visible child (and only on this one). When the user scrolls the recycler view, second item should overlap the first, and the first will slowly fade out. reverse animation when sliding down.
In short, when the list scroll top for example, when the first item goes offscreen and want to change that behaviour. Instead of going offscreen, it slowly fades based on scroll dY and stay in the same position.
Any hints would be much appreciated.
I think this answer may can help you. I used code like this in my app and work smootly.
https://stackoverflow.com/a/29714138/2971619
Hope to be usefull for you too!
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
I have a button in each item of a ListView whose background is defined by an XML, one background when enabled and another when disabled. When the ListView loads, it comes out correct. But, for some reason I can't figure out, if I scroll down and then scroll back up, the wrong background shows up.
I'd like to know the solution to this problem, but besides that, in general what I want to accomplish is this:
I have a button in the ListView to take the user to the website for the given item. If there is no website, I want the button to disappear, or be disabled. I seem to have the same problem with both options.
Thanks in advance for your efforts
It seems most likely that the problem lies with your getView() method. Android recycles views to save memory, so, for example, when you scroll down, it calls getView(int, View, ViewGroup) on your adapter where View is the item that just left the top of the screen. If you're not re-populating the item with the new data from the adapter, (ie, just returning convertView) it will put the View that left the top of the screen where the "new" one should be.