简体   繁体   English

如何在viewpager中同时显示2个片段?

[英]How to have 2 fragment showing at the same time in a viewpager?

I'm trying to do the same thing as in the google play. 我正在尝试做与Google Play中相同的操作。 In movies, when you are on the Home tab and you scroll to the categories tab which is on the left, the categories fragment open only to half of the screen and the other half is still the home tab. 在电影中,当您位于“主页”选项卡上并滚动到左侧的“类别”选项卡时,类别片段仅在屏幕的一半打开,而另一半仍然是“主页”选项卡。 How can i implement this using actionbar tabs with a viewpager? 如何使用带有Viewpager的操作栏标签实现此目的?

主页标签

类别标签

It's very well explained here: FragmentPagerAdapter Swipe to show ListView 1/3 Screen Width 在这里对其进行了很好的解释: FragmentPagerAdapter滑动以显示ListView 1/3屏幕宽度

In PageAdapter : 在PageAdapter中:

@Override
public float getPageWidth(int position) {
if (position == 0) {
    return(0.5f);
} else {
    return (1.0f);       
}

Good luck 祝好运

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM