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 中滑动半页(来自兼容包)
基础教程推荐
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
