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:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
