in terms of performance, what will be considered better.
having nested layouts (2-3 nested layouts, reused with tag> or using Recyclerview?
Does it matter if the layout is part of an item in another Recyclerview?
In terms of updating the data when something changes?
The number of items\layouts is static (2), so there's no way it will become larger in the future.
Thanks.
I think you need using ConcatAdapter in RecycleView when scroll mutil view type. Beside you can using mutil-type, custom header, footer. Good luck :D
Related
I'm a flutter user trying out kotlin dev first time, but im kinda confused what the best alternatives for this type of layouts are.
I understand that I use recyclerview for a dynamic number of items. And since theres two dynamic ones (one for number of sets, one for each exercise). Do I use two nested recyclerviews?
It really depends what you're doing here. A RecyclerView is basically a list, so it's a good choice for a scrollable set of items - which it looks like your Exercises are. But how do you want to display those weights?
It's possible to make them scrollable, so some of them aren't visible on the screen (the categories on the Play Store act like this). For that you would need a nested scrolling view of some kind - could be a horizontal RecyclerView, or it could just be a ScrollView wrapped around a LinearLayout you throw views into.
But the other option you might want, is that for each Exercise, all of its weights are visible in a grid of some kind. No scrolling, all there up-front to see and poke at. So the first question is which of those do you want?
I'd assume it's this version - where you can easily visualise the contents - in which case you're not talking about nested lists, it's just one list, and each item contains a grid you can add things too. For that setup, there's GridLayout, TableLayout, and ConstraintLayout Flow (which acts like FlexBox if you're familiar with that). So in the layout for an item in your list, you have a container for stuff, and you put the stuff in it, and the container expands vertically as needed
I have two RecyclerView inside the NestedScrollView and I need track viewed items of my RecyclerViews. But problem that using nestedScrollView the recycler pattern doesn’t work and all the views will be loaded at once because wrap_content needs the height of complete RecyclerView so it will draw all child Views at once.
Is there any way to track of the viewed items with this approach? Please help me.
never use RecyclerView inside NestedScrollView because your ViewHolders will not be recycled and you will be in danger of OutOfMemoeryExceptions, it may work for lists with small sizes but as the list size increases it becomes worse,
instead of using one ScrollView and 2 RecyclerView as child
you have to completely remove ScrollView and instead of that, use one RecyclerView with multitype ViewHolders, in other words you need to combine those 2 RecyclerView in on RecyclerView .
To achieving this you can combine those adapters manually or you can use ConcatAdapter that depends on what you want, this link may also help you if you want to use ConcatAdapter but that is not necessary.
then you can have different approaches to track the visibility of viewHolders like layoutManager.findFirstVisibleItemPosition() and etc.
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.
My question is about best practices in Android in terms of using ScrollView to scroll other views and widgets. This is to know when to use a ScrollView to eliminate redundancy of scrolling if scrolling is possible in a given widget/view/layouts.
So I notice that there are instances where I don't really need to use ScrollView to make things scrollable. Few of the widgets/views/layouts that I know of are TextView and ListView. This is supported according to this documentation.
You should never use a ScrollView with a ListView, because ListView takes care of its own vertical scrolling. Most importantly, doing this defeats all of the important optimizations in ListView for dealing with large lists, since it effectively forces the ListView to display its entire list of items to fill up the infinite container supplied by ScrollView.
The TextView class also takes care of its own scrolling, so does not require a ScrollView, but using the two together is possible to achieve the effect of a text view within a larger container.
My question is, are there other widgets/views/layouts that handles their own scrolling other than the two I have stated above and the documentation has. Maybe there are others that are scrollable or other methods to make things scrollable other than the default of some widgets and by using the ScrollView.
Preferred answers must be base on experience and documentation (other than what I've shown). Thanks in advance for any good answers.
WebView is one other class that does its own scrolling. My "best practice" advice is to use ScrollView to add scrolling to an arrangement (usually vertical) of fixed-size widgets. As you have noted, variable-sized widgets such as ListView provide their own scrolling.
if you read the official documentation you will find that tell you when not to use ScrollView:
You should never use a ScrollView with a ListView, ListView Because Takes Care of Its Own Vertical scrolling. Most importantly, doing all of the defeats esta Important optimizations in ListView for dealing with large lists, since it forces the ListView Effectively to displays its Entire list of items to fill up the container supplied by ScrollView infinite.
More information here.
I'm on a research to design a ListView with horizontal scroll of views - something like in the facebook app.
I also need to implement a caching for the horizontally scrollable views.
Some of the options I can think of are:
Horizontal scroll view items.
A ViewPager which I understand is not quite good for this task.
What would be my way to go on this?
I've read some StackOverflow questions and am still researching but none of what I read so far also implement caching for the scrolled horizontal views.
Just use two RecyclerViews which are nested. The backing data is a two dimensional array as the layout is two-dimensional. The outer RecyclerView passes the data for the inner RecyclerView when the onBindViewHolder of the adapter is called. Additionally you may also use different layouts or ViewHolder respectively if the inner view consists only of a single item and does not require horizontal scrolling.
Some references about implementing RecyclerViews
Here: http://www.bignerdranch.com/blog/recyclerview-part-1-fundamentals-for-listview-experts/
Here: https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html
and here: https://developer.android.com/training/material/lists-cards.html
This will help you. You can use caching while scrolling. For example if you load images with horizontal scroll bar, you could use picasso library for catching and loading images.
Dont think big we have some library that will do what you want below listed some of them
https://github.com/sephiroth74/HorizontalVariableListView
https://github.com/EmirWeb/parchment
https://github.com/MeetMe/Android-HorizontalListView
any one this link will help you i belive
https://guides.codepath.com/android/Implementing-a-Horizontal-ListView-Guide
https://www.airpair.com/android/horizontal-image-galleries-android-studio