I have a recyclerview with items having weights. Every item is being displayed differently (the width) even though the weight is same. I want equal widths for all the textviews in each item.
I figured out the mistake. I forgot to make layout_width 0dp. Thanks
Related
I read that RecyclerView should never have layout_height="wrap_content" because it won't recycle the views.
I tested this by creating that with 100 items.
I scrolled to the bottom and used layoutInspector. It showed only a couple items under the RecyclerView, not 100. I also tested with a recycerview layout_height=200dp and saw the same result.
It seems the views are still being recycled. Am I misinterpreting what he's saying or are layout_height=wrap_content and layout_height=fixedDp irrelevant to recycling?
android:layout_height values of wrap_content or a fixed height are irrelevant to recycling.
However, android:layout_height="wrap_content" is not a good idea in general for vertically-scrolling widgets, such as a RecyclerView with a vertical LinearLayoutManager. Since the content varies, the size may be unpredictable. Use something else to control the height to be what you want regardless of the content, such as constraining its top and bottom within a ConstraintLayout.
A single item in my RecyclerView consists of 3 charts but the last one turns out minuscule. How do I make them all appear their full size/total size bigger than 1 page?
To sum up: 1 item made up of 3 charts. Many such items in a RecyclerView.
Things that I've tried:
1. LinearLayout with equal weights.
2. RelativeLayouts with the heights explicitly mentioned.
Thing I'm trying to achieve:
What I have now:
I looked at MPAndroidChart's example and it uses ListView and not RecyclerView. Thanks in advance!
EDIT:
The answer was Wrapping the entire thing in a ScrollView.
I would like to reproduce this behavior on Android
This is a simple horizontal RecyclerView where all the child items can be expanded with an animation.
https://www.youtube.com/watch?v=JI323jA67x0
But unfortunately, I don't see how to achieve this with standart recyclerview.
I have had multiple ideas, but I don't see how I can achieve in a correct way.
1) modifying the whole recyclerView heigth at runtime, but I need to mesure a children and give it an height with measured dp ?
2) setting visibility to all children TextViews from Visible to Gone, but seems horrible...
3) ???
Thank a lot for any advice.
Can I use more than one ListView in a layout, because my list adapter is considering the ListView with id "list", how to set the adapters for the remaining list views?
You can't do it with a ListActivity. You can do it with your own Activity subclass, but you have to be a little careful about defining the heights for vertically stacked ListViews. One way to do it is to put them in a LinearLayout, set the layout_height of each to 0px, and set the layout_weight of them to non-zero numbers in proportion to how much space you want each to take up. (For equal-height lists, for example, set the layout_weight of each to 1.)
I have a listview in which there should be different divider height
between different rows. So, how can we set the divider height
dynamically?
Suppose, I have 10 rows and there should be a divider height of 5
between first 2 rows and then there should be a divider height of 1
between next 5 rows and so on.
Can someone let me know the way of doing this?
One way would be to make the dividers rows. Set them as not enabled in your isEnabled adapter method. I do that for section headers, but it is almost the same thing. Another way would be to manually lay out your whole list by implementing onLayout. If the dividers can be empty space, it might work to set top or bottom margins for the root view of your rows. In xml that would be:
android:layout_marginTop='5px'
Otherwise, just make the dividers part of the rows.