上一页和下一页可见的Android ViewPager?

Android ViewPager with previous and next pages visible?(上一页和下一页可见的Android ViewPager?)
本文介绍了上一页和下一页可见的Android ViewPager?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建一个水平视频库.

I am currently building a horizontal gallery of videos.

我想制作这样的东西,只有一个视频居中,上一个和下一个视频的一部分:

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

我首先选择了 Gallery,但它的局限性让我看了为了别的东西.我想显示一个页面指示器,但使用 Gallery 很难实现.

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.

第二种选择是选择 来自 Android 兼容性库的 ViewPager.我找到了一种在其上实现 页面指示符 的方法.但是现在,如何部分显示左右页面呢?

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?

推荐答案

我使用负页边距来部分显示下一页和上一页.fading edge 属性可用于使上一页/下一页淡化:

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);

此功能还需要最新的支持包(2011 年 10 月第 4 版)

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

这篇关于上一页和下一页可见的Android ViewPager?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)