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.
Related
I have a RecyclerView with a fixed height for its items. These items have a expanding menu that does not fit within the ViewHolder, so I would like for it to extend beyond its parents width and height. You can see the issue here:
Is this even possible to achieve?
I found this question as I faced the same issue with an animation that should expand beyond the RecyclerView item bounds.
#Martin Marconcini's comment suggesting to add android:clipChildren="false" to the RecyclerView helped me a lot.
I had to add it also to the item's layout which is a FrameLayout in my case.
After adding that, my animation successfully expanded beyond it's parents bounds.
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.
I have Horizontal cyclic ReacycleView. but I want in recycle view's middle item(ImageView) height be greater as compared to other side items.
Recycle view items
That means if any item in the center of RecycleView, it's height should be greater in RecycleView itself.
You can use a different layout for your middle item by implementing getItemViewtype() in your adapter. Similar question and answer here should point you in the right direction.
I created a sample app with this functionality and here is code.
Let me know if you need some explanation.
You need to create A custom layout manager and Item Transformer
CenterLayoutManager
Repository
ScaleTransformer
I am experimenting with a RecyclerView and it currently displays four CardViews vertically on the screen. Using an adapter, I am able to resize each CardView's height equally in the space given.
What I'm trying to accomplish:
On click, I would like the selected RecyclerView child to expand to fullscreen. Currently, I can programmatically set the height and expand the selected CardView dimensions, but the other CardViews after it are pushed down off-screen. How can I have all the selected CardView positioning become absolute, and lock the other views positions and expand "over" them? Is this the proper approach, or should I be looking into shared-element transitions or something else?
Side-ask: Is there a way to control all top/left positioning of RecyclerView children in an adapter?
The comments above seem to be correct - after looking into shared transitions, I found numerous examples performing the exact behavior I described. Crediting #AmratSingh since he answered first.
If it helps anyone, here is the one I am following currently: Michael Scammell - Shared Element Transitions
This one in particular: Shared element transitions within a RecyclerView
I searched for a few hours over the internet but I didn't find any example or documentation explaining how to create an horizontal list view with fixed number of elements.
Basically, I would like to have, let's say 3 elements out of n(total number of elements) which are displayed on the screen without taking into consideration the size of the scree. The elements can be bigger or smaller proportionate to the screen but the number of visible elements should be the same, fixed. see the image.
How can I do that? Any hint is appreciated! Thank you!
You can use TwoWayWiew third party library (i dont really recommend this solution), or if you want to avoid to use lib for this, just use RecyclerView, and you can set HORIZONTAL param to layout manager.
I would not use a ListView for this, but a RecyclerView instead. Performance is better in a RecyclerView and I honestly find them easier to work with. You can allow for horizonatal scrolling via the LayoutManager for your RecyclerView.
If don't mind scrolling horizontally by 3 items you could use a ViewPager with each View containing a LinearLayout (orientation horizontal) with three of your elements that have a
android:layout_width="0dp" and an
andriod:layout_weight="1"
for even distribution.
When you "scroll" you would just animate the next "page" into the screen bringing in the next 3 elements.
This might not be the most elegant solution but I think it would behave the way you want.
use the linear layout with its orientation set as horizontal under the relative layout