Swipe half page in a ViewPager (from compatibility pack)(在 ViewPager 中滑动半页(来自兼容包))
问题描述
我正在使用带有 PageAdapter
(来自兼容包 v4)的 ViewPager
在水平框列表之间滑动.问题是我的第一页中的第二个框是第二页中的第一个框(从视觉上和概念上).像这样的:
I am using a ViewPager
with a PageAdapter
(from the compatibility pack v4) to swipe among a horizontal list of boxes. The problem is that my second box from the first page is the first box in the second page (visually and conceptually). Something like this:
我现在的做法很有效.但是,这变得有点奇怪,因为在滑动的中间有一个相同的框出现两次的情况(就像它在图像中显示的那样).
The way I am doing now it works. However, this becomes kinda weird because at the middle of the swipe there is a situation that the same box appears twice (like it is shown in the image).
有办法只刷半"页吗?
盒子是一种抽象.实际上每个盒子都是一个 ListView
我创建不同的页面只是改变每个 ListView
的适配器.
The boxes are an abstraction. In fact each box is a ListView
and I create different pages just changing the adapter of each ListView
.
推荐答案
- 每页创建一个片段
- 重写 PageAdapter 中的 getPageWidth() 以显示多个页面
代码:
@Override
public float getPageWidth(int position) {
float nbPages = 2; // You could display partial pages using a float value
return (1 / nbPages);
}
这篇关于在 ViewPager 中滑动半页(来自兼容包)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 ViewPager 中滑动半页(来自兼容包)


基础教程推荐
- Android文本颜色不会改变颜色 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01