• Stars
    star
    599
  • Rank 74,745 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

👍 A PageTransformer library for Android ViewPager,have some Banner styles. ViewPager 实现轮播图、实现卡片切换。

PageTransformerHelp

GitHub issues  GitHub forks  GitHub stars

This is a PageTransformer library for Android ViewPager;There are many custom PageTransformer styles.Be able to help you when you use ViewPager.

Version Code

关于 ViewPager 的各种用法详解教程

Download the demo apk

Styles

Banner Style

Style Name Demo Pic
AccordionTransformer AccordionTransformer
BackgroundToForegroundTransformer BackgroundToForegroundTransformer
CubeInTransformer CubeInTransformer
CubeOutTransformer CubeOutTransformer
DepthPageTransformer DepthPageTransformer
FlipHorizontalTransformer FlipHorizontalTransformer
FlipVerticalTransformer FlipVerticalTransformer
ForegroundToBackgroundTransformer ForegroundToBackgroundTransformer
ParallaxTransformer ParallaxTransformer
RotateDownTransformer RotateDownTransformer
RotateUpTransformer RotateUpTransformer
ScaleInOutTransformer ScaleInOutTransformer
StackTransformer StackTransformer
TabletTransformer TabletTransformer
ZoomInTransformer ZoomInTransformer
ZoomOutSlideTransformer ZoomOutSlideTransformer
ZoomOutTranformer ZoomOutTranformer

Card Style

Style Name Demo Pic
AlphaAndScalePageTransformer AlphaAndScalePageTransformer
AlphaPageTransformer AlphaPageTransformer
CascadingPageTransformer CascadingPageTransformer
RotateDownPageTransformer RotateDownPageTransformer

Download

You can download a jar from GitHub's releses page.

Or use Gradle:
Step 1. Add it in your root build.gradle at the end of repositories

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
    compile 'com.github.OCNYang:PageTransformerHelp:v1.0.1'
}

Or Maven:
Step 1.

<repositories>
	<repository>
	    <id>jitpack.io</id>
	    <url>https://jitpack.io</url>
	</repository>
</repositories>

Step 2.

<dependency>
    <groupId>com.github.OCNYang</groupId>
    <artifactId>PageTransformerHelp</artifactId>
    <version>v1.0.1</version>
</dependency>

How do I use PageTransformerHelp?

Use Banner Style

Add your ViewPager in XML;And then:

...
mViewPager = ((ViewPager) findViewById(R.id.viewPager));
mViewPager.setPageTransformer(true,new ParallaxTransformer());
...

If you want a ViewPager with Title and Indicator,We recommend that you customize a ViewPager.
Here is an BannerViewPager for your reference, but we do not recommend that you use it directly unless it meets your requirements.
PageTransformerHelp 内提供了一种带有标题和指示器的 BannerViewPager,这里只是供大家根据需求自定义 ViewPager 时作为参考(大家只需要复制里面的代码,修改一下标题和指示器的布局文件即可)。不建议直接使用,如果你愿意也可以直接使用。

Use BannerViewPager

Add BannerViewPager in your XML;And then:

mBannerViewPager = ((BannerViewPager) findViewById(R.id.bannerViewPager));
mBannerViewPager
	.setData(List<BannerItemBean>,//set data
	    new ImageLoaderInterface() {
	        @Override
	        public void displayImage(Context context, Object imgPath, ImageView imageView) {
                //Set your own image loading method according to your needs
                //Glide.with(context).load(imgPath).into(imageView);
	        }
    })
    .setPageTransformer(new ParallaxTransformer())
    .setAutoPlay(false)
    .setOnBannerItemClickListener(new BannerViewPager.OnBannerItemClickListener() {
        @Override
        public void OnClickLister(View view, int currentItem) {
            ...
        }
    })
    .setHaveTitle(true);//set the title show or hide

Use Card Style

Add ViewPager in XML:

<LinearLayout
    ...
    android:clipChildren="false"
    ...>
	...
	<android.support.v4.view.ViewPager
        ...
        android:layout_marginLeft="80dp"
        android:layout_marginRight="80dp"
        android:clipChildren="false"
        .../>
	...
</LinearLayout>

You should set android:clipChildren="false" for your ViewPager and ViewPager's parent;And set layout_marginLeftlayout_marginRightfor your ViewPager.
And then set setPageMarginsetPageTransformer in the code:

...
mViewPager = ((ViewPager) findViewById(R.id.cardViewPager));
mViewPager.setOffscreenPageLimit(3);
mViewPager.setPageMargin(40);
mViewPager.setPageTransformer(true,new AlphaPageTransformer());
mViewPager.setAdapter(...
...

In the end

If you have some other nice PageTransformer, you can create a pull request. If you find some bugs,tell me through create an issue.

Like it please give me a star.

如果你有更好的自定义 PageTransformer 可以提交给我;
同时如果你喜欢这个项目,欢迎 Star。

关于这篇文章更详细的教程,请看:ViewPager 超详解:玩出十八般花样

Thanks

LICENSE

Copyright 2017 https://github.com/OCNYang | OCN.Yang

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

Android-Animation-Set

📚 Android 所有动画系列详尽教程。 Explain all animations in Android.
Java
2,804
star
2

QBox

🐈 RxJava+Retrofit+Okhttp+Glide + A life tool App, contains modules: news; jokes; constellation fortune; LED; weather; calendar; two-dimensional code, and more ... 小秋魔盒是一个生活工具 App,主要功能有:新闻资讯;微信精选美文;笑话趣图;星座运势;LED字幕;天气;日历;二维码;手电筒;老黄历。在开发中尽可能多的用了目前比较流行的框架和库。
Java
1,380
star
3

ContourView

🦄 利用本库绘制出贝塞尔曲线魔炫背景。Customize view:Draw the magic dazzle background with Bézier.
Java
575
star
4

RecyclerViewEvent

RecyclerView onItemClick、onItemLongClick、drag、swipe、divider、reuse disorder RecyclerView 梳理:点击&长按事件、分割线、拖曳排序、滑动删除、优雅解决 EditText 和 CheckBox 复用错乱问题、定向刷新、DiffUtil、局部刷新
Kotlin
299
star
5

CartLayout

🦄 使用 RecyclerView 实现店铺分组购物车。 高仿京东购物车、高仿淘宝购物车、高仿天猫购物车
Java
130
star
6

AndroidBang

《Android 江湖花名册》
114
star
7

flutter_ui_kit

UI Kit of CookMe by Flutter;
Dart
45
star
8

FontTest

屏幕适配的顶级淫技:使用 TextView 来显示图片
Java
27
star
9

AnchorImageViewDemo

图片锚点定位;【图片画圈定位 请移步 👉https://github.com/OCNYang/DrawPartViewDemo】
Java
15
star
10

ConstraintLayout_Guide

全面讲解 ConstraintLayout 相关知识,目前最强大的布局控件,没有之一,不接受反驳。
Kotlin
8
star
11

DrawPartViewDemo

🎯 图片画圈定位;【图片锚点定位 请移步 👉https://github.com/OCNYang/AnchorImageViewDemo】
Java
6
star
12

Flutter-Notes

收集学习 Flutter 不错的教程。
5
star
13

Linux

开启 Linux 之行
5
star
14

Support

索拉卡-通用库
Java
2
star
15

GSYVideoPlayer-master

Java
1
star
16

OCNYang

GitHub 首页 简介
1
star
17

iconfont2strings

批量将 iconfont 中的字符转换成 Android 中的字符串资源 strings.xml
Java
1
star
18

EFall

💌 筑一座柔城,愿每一次心的疲惫,都能在这得到安慰......
1
star