Android的ViewPager用previous和下一页可见?下一页、Android、ViewPager、previous

2023-09-12 10:45:57 作者:小野琳

我目前正在建设的视频水平画廊。

I am currently building a horizontal gallery of videos.

我想做出这样的事情只有一个视频中心和previous和接下来的视频部分:

I'd like to make something like that with only one video centered and part of previous and next videos:

我先选择了一个图库但它的局限性却让我去找别的东西。我想展现一个页面的指标,这是非常难以实现用一个画廊。

I first opted for a Gallery but its limitations made me look for something else. I'd like to show a page indicator and it is quite difficult to implement using a Gallery.

第二个选择是去一个ViewPager从Android的兼容性库。我找到了一种方法来实现页指示灯权。但现在,如何部分显示左,右页?

The second option was to go for a ViewPager from Android Compatibility library. I found a way to implement a page indicator over it. But now, how to partly show left and right pages?

推荐答案

我用了一个负面的页边距部分地显示下一个和previous页面。衰落的边缘性,可用于制造previous /下一页褪色:

I used a negative page margin to partly show the next and the previous pages. The fading edge property can be used to make previous/next page fade:

ViewPager examplePager = (ViewPager) findViewById(R.id.exampleView);
examplePager.setPageMargin(-50);
examplePager.setHorizontalFadingEdgeEnabled(true);
examplePager.setFadingEdgeLength(30);

也是需要的最新支持包(修订版4,2011年10月),这个工作

The lastest support package (revision 4, October 2011) is also required for this to work