Guys can anyone give me some advice? I got this sc...
# android
a
Guys can anyone give me some advice? I got this screen. The green and white part is a recyclerview with its height set to WRAP_CONTENT. The entire recyclerview is constrained to all edges of the screen, and yet, as you can see, it is centered, with its content being wrapped... What i would expect is the content to be positioned from the top, not from the center. IS there a way to do this?
a
Remove wrap content and set height to 0dp. Constraints will take care of it
👌 5
a
Ohh my shit it actually worked! 😄 Can you explain what happens so i can remember it? 🙂
a
When you set it to wrap content the RecyclerView takes as much space as the views within and then the constraints apply on top of it to make it center. If you don't apply wrap content and use 0dp then the RecyclerView takes as much space as the constraints provide it.
To better see this visually, try setting background to RecyclerView and see what it does in wrap content and what it does with 0dp.