Hello currently I am working on android and I am stuck to implement the structure picture above.
I need to add and delete the CardView in the list.
I have tried it with RecyclerView and also used NestedScrollView to avoid double scroll, but I
faced a problem that the animation is not available anymore when deletion because when
deleting an item, the size of the recyclerView is forcibly reduced by NestedScrollView, so the
animation cannot be operated normally.
So what I want to know is if there is any way to implement it without NestedScrollView
If not, how can I restore the animation working?
NestedScrollView in this case is unnecessary. You'd better use RecyclerView only with multiple view item types
Related
I have a LinearLayout inside a ScrollView and I want to create the ilusion of endless scrolling by removing the views that are not visible and putting them as the next elements in the list (basically i do a linearlayout.removeView(viewOutOfScreen) and then linearlayout.addView(viewOutOfScreen). The problem is, every time this happens the view that is currently visible ends up in the top of the ScrollView. I tried doing a scrollView.scrollTo(0, -viewOutOfScreen.contentHeight) and it kinda works but the transition generates an horrible tearing artifact.
Also I'm not able to use RecyclerView given that the views are WebViews with very specific settings and executing js, so i nedd to reutilize/reposition them manually (cant't create more than i initially have).
I recommend using a nested RecyclerView because, it does exactly what you are trying to achieve manually. It recycles views which are out of the screen.
Also I'm not able to use RecyclerView given that the views are WebViews with very specific settings and executing js, so i nedd to reutilize/reposition them manually (cant't create more than i initially have).
So what if they're WebViews? You could just manually cache the views you want to display (ignoring the "recycling" part of RecyclerView) and return the View you want for each index instead of letting the RecyclerView delete and recreate them.
I am trying to achive this:
First I tried by putting all my recyclerviews (with WRAP_CONTENT) inside a nestedscrollview. That worked, but the performance was awful. Then I tried to set a height for my recyclerviews, that was a lot better (especially the first gridlayout and the horizontal linearlayout loaded very fast), but still had the problem with the dynamic "category" part.
Now I am trying to put all my recyclerviews inside a single recyclerview with different viewtypes. Since that is a pretty big deal (I need to refactor a lot of code because I have diveded every area from the screenshot inside a single fragment and now I need to put all that code inside an adapter) I wanted to ask if I can actually expect any gain from this, because in the end its again a "nestedscrollview" (made by myself, but...). Or if there is some other "best practice" way to achive this layout.
Thank you
Edit:
As expected this didnt do the trick neither. When just the two first recyclerviews are added as viewtype it scrolls and loads smoothly. But as as soon as I try to add the category items (below the category), I notice a lag and especially when selecting multiple categories and scrolling fast up, there is noticable lag. I guess I will have to change my layout and move the category selection part inside a separate view, just need to come up with a user friendly solution. But its acutally quite dissapointing that, in my opinion such trivial task, laying out multiple tables, is such a pain in the ass on android.
I didn't manage to get it working with standard android stuff.
Now I am using epoxy from airbnb ,and I have converted all my views from nestedscrollview to the epoxy recyclerview. Its a great library, and airbnb use it too for all their views.
Nevertheless it's sad that the android dev team doesn't address this problem and provide a solution besides the info "don't nest multiple scrollviews(recyclerviews) that scroll into the same direction".
You can use Recyclerview in recyclerview.
https://irpdevelop.wordpress.com/2016/02/10/horizontal-recyclerview-inside-a-vertical-recyclerview/
And make sure to use multiple view types.
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.
I am using RecyclerView and CardView in my project, most parameters of these two widget were default, I haven't customize it much, but two questions came up.
Why those CardViews will flash one second when pull down to refresh data which is using SwipeRefreshLayout, can I stop this effect?
Why those CardViews will adjust position automatically when scrolling? Can I stop this effect?
The layout I am using for RecyclerView is StaggeredGridLayout, it's inconvenient to post code here beause there too many code in my project to use those widget, so you can tell me which part I should post here, thanks.
I am using a ScrollView to display a list of items that are inflated on runtime. Like a feed of updates for the user.
While thinking about the options i got to let the user update the view with new notifications I thought about the pull to refresh feature in the twitter app.
Anyone got any idea how and if can it be implemented with a ScrollView ?
Saw there are some implementations for that using ListView but I don't like the idea of changing all of my platform to gain this refresh effect.
There is a solution introduced for implementing pull to refresh for various component which are scrollable like listview and scroollview.
Look at ChangeLog link https://github.com/chrisbanes/Android-PullToRefresh
ListView with just one element can be treated as a ScrollView. You can use the implementation for pull-to-refresh ListView and add just one item in it. I had used this trick in the past.
You can do that. You can increase the top margin of the scrollview when the user moves the finger down and the scrollview it's on it's top. Then on release fire the update and decrease the margin with animation.(You have to create your own animation to pull that off). That's the idea. If you want more particular help ask what you cannot implement.