androidandroid-recyclerviewviewandroid-listviewandroid-viewgroup

Add view to ViewGroup only if there is enough space left


I have scrollable horizontal RecyclerView filled with same size items.

I need to change behaviour of that ViewGroup and have 4 requirements:

I tried to play with Flexbox-layout but I am not sure if this is a correct tool to achieve it. Also before I started trying to implement it by myself (measure; add item if space left > item.size), I wanted to ask if there is already easy solution for this.


Solution

  • I have created EllipsizeViewGroup for that. Layout is based on LinearLayout. You can add more views dynamically.

    https://github.com/Bresiu/EllipsizeViewGroup/blob/master/app/src/main/java/com/bresiu/ellipsizeviewgroup/EllipsizeViewGroup.kt