Can HorizontalView And ScrollView Hold Fragments?

六眼飞鱼酱① 提交于 2019-12-11 11:08:20

问题


I just would like to ask if these Layouts can hold fragment/multiple fragments. I base this on google play store.

Sorry for bad logic.


回答1:


Yes, scroll views can hold multiple fragments.

However, managing the fragment stack gets tricky.

Because fragmentManager/ChildFragmentManager will only maintain stack for one container, if I am not wrong.

As long as you don't add them dynamically in run time,it is easy.

i.e. if the fragments are described in the scroll view from xml layout and you don't perform fragment transactions, you are all good.

I have dealt with the same issue, and cost me a lot of trouble but I did implement it. However, if you end up with such a requirement, you might be doing something wrong give other solutions a go and see if you can avoid this requirement.

NOTE : I don't think Google play uses fragments in Scroll Views. What I see them do is have RecyclerViews within recycler views, if this is what you are talking about

i.e. There are Horizontal RecyclerViews within Vertical RecyclerViews.

In case you are not aware, RecyclerViews are the new version of listViews, they are more powerful and perform way better.

I suggest you don't use listViews, but use RecyclerViews instead.



来源:https://stackoverflow.com/questions/37192331/can-horizontalview-and-scrollview-hold-fragments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!