How to get several ViewPagers into a ScrollView?

泄露秘密 提交于 2019-12-01 00:15:21

On your LinearLayout, in your XML. Set android:weightSum="2". For each viewpager, set android:layout_weight="1". Also, set the height of each child of the LinearLayout to 0dp. That should do the trick

There is indeed something fishy with using multiple ViewPager. I am inflating several views, each holding a ViewPager, and only the first ViewPager got populated with data from its adapter. However, if I give each ViewPager an unique id, all of them gets populated.

I have a container whose only child is a ViewPager:

ViewPager pager = (ViewPager) pagerContainer.getChildAt(0);
         pager.setId(i);

where i is a positive index of a loop.

The issue is related to by default height of ViewPager as by default it is taking "fill_parent" , which we are not able to reset with "wrap_content". The solution which i found that fixing the height to some hard code value will return you all the view pager item appear in your screen.

I know this is some fishy solution but it works fine for me and i hope it should work with you.

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