How linearly increase and decrease height of Horizontal RecycleView in android - android

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

Related

How to make evenly spaced Grid Layout with dynamically added square items

I would like to create a grid layout in which each item is taking as much space as possible (minus padding), but only as long as there are columns available (after that the next item would be inserted in the next row while keeping the size). Additionally, each item must be a square and is added dynamically.
Example layout with 10 items would be as follows:
I have tried to achieve this by setting weights, ratio constraints, overriding onMeasure - but I just can't get it to work. I would be happy with either a programmatic or an XML-based solution (as long as each item can be added programmatically). I would prefer the solution to be in Kotlin, but I would be happy with a Java-based one as well.
It's probably worth saying that each item in the grid layout is a layout (RelativeLayout as of now) to make inflating it and setting a layered background drawable programmatically easy.
I think you might be able achieve what you want with a different Layout
Have a look at https://github.com/google/flexbox-layout it has lots of methods to control how the cells grown or shrink and includes automatic or manual wrapping of cells.
Take a look at RecyclerView. You would need to pass GridLayoutManager. This tutorial may or may not help you. For square items, I suggest using CardView but it's not necessary. If you are targeting tablets as well as smartphones, check this out. And for dynamically adding new items, you should notify recyclerView's adapter. See this link. You can also extend RecyclerView or GridLayoutManager for more control over items.

RecyclerView Item extend beyond boundaries

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.

How can I have RecyclerView children ignore relative positioning?

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

How can I create an horizontal ListView in Android with fixed number of items?

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

Multi column listview layout

How to do a layout like this? I currently use a listActivity and I need the same experience with this kind of layout.
You can use Staggered Grid View library. Also check and Quilt View. This is what you need.
To get this effect, you should create two list views and link the scrolls of both lists.
Define a OnScrollListener on both listviews and when "onScroll()", move programatically the other list. I think if all images are cached you shouldn't have delays.
You can use Staggered Grid View library. But there you need to mention height of each image pragmatically to set height of list view. Else when you scroll to end and come back to top, the alignment of images on top will get disturbed
You have to use GridView
You can refer this or this.

Categories

Resources