square / cycler

Apache License 2.0
791 stars 27 forks source link

Add a default layout manager when using adopt()? #28

Open dimsuz opened 4 years ago

dimsuz commented 4 years ago

When I started experimenting with this library I initially went with Recycler.create() which also created a layout manager for me. Then I decided that I don't want to manually call .addView() to put RV into my parent layout, so I placed RV in xml and called .adopt(findViewById()). Suddenly it crashed, because .adopt() doesn't create a layout manager, and RV throws an exception.

This feels a bit asymmetric and not intuitive. Would it be possible to add a layoutProvider argument to .adopt? I guess it could default to RV existing layoutManager...

My point is that it shouldn't matter if I created RV programmatically or inflated it from xml it should behave the same. Most other View work this way, e.g. FrameLayout doesn't apply some additional styling or whatever based on if I'm inflating or creating it from code.

helios175 commented 4 years ago

Sorry about the "delay". You're right. I will look into it soon. There might be some historic reasons for which the API is not symmetric but it doesn't need to be that way.

helios175 commented 4 years ago

Addressed in #36 . I still have to publish a new version including that part.