https://kotlinlang.org logo
u

ursus

03/08/2019, 3:49 AM
can one instance be technically part of 2 viewgroups?
e

edwardwongtl

03/08/2019, 3:50 AM
No, this is forbidden to add a view(which has a parent view) to another viewgroup.
u

ursus

03/08/2019, 3:51 AM
yea, thought so, well then it needs to be viewgroup.removeView(toBeCachedView)
okay this is going to be a mess 😞
e

edwardwongtl

03/08/2019, 3:52 AM
So you still need to detach the emoji view from the flow layout when the message view is recycled
u

ursus

03/08/2019, 3:52 AM
yes, hence modifing the original layout, thats going to be trouble
e

edwardwongtl

03/08/2019, 3:53 AM
But the original layout is going to be recycled, why is it causing trouble?
u

ursus

03/08/2019, 3:54 AM
not sure, never tried transfering view from one viewgroup to another
how about recyclerview instead of flowlayout, but with flowlayout manager, and wrap_content height to make it unscrollable and share viewpool
e

edwardwongtl

03/08/2019, 3:55 AM
The action of detaching emoji view should be perform at the time which the original layout is being scrolled off screen, so that onViewRecycled will be called on the parent view.
Using a flowLayoutManager can be a way, but I think the effort required is similar to this approach
u

ursus

03/08/2019, 3:56 AM
okay Ill try it, wonder if it will work
k

Katya Yurukova

03/08/2019, 6:23 AM
you can try FlexboxLayoutManager https://github.com/google/flexbox-layout
3 Views