Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
Add interface to setHGap between two pages
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAfc committed May 19, 2017
1 parent ffe2e37 commit c241c62
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README-ch.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ UltraViewPager继承自RelativeLayout,将ViewPager和indicator置于其中,
竖向滑动是通过在ViewPager的onInterceptTouchEvent和onTouchEvent中交换横竖向的event location,同时设置特殊PageTransformer实现,详见源码.

#### 使用方法
版本请参考mvn repository上的最新版本(目前最新版本是1.0.3),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖:
版本请参考mvn repository上的最新版本(目前最新版本是1.0.4),最新的 aar 都会发布到 jcenter 和 MavenCentral 上,确保配置了这两个仓库源,然后引入aar依赖:

```
//gradle
compile ('com.alibaba.android:ultraviewpager:1.0.3@aar') {
compile ('com.alibaba.android:ultraviewpager:1.0.4@aar') {
transitive = true
}
Expand All @@ -45,7 +45,7 @@ compile ('com.alibaba.android:ultraviewpager:1.0.3@aar') {
<dependency>
<groupId>com.alibaba.android</groupId>
<artifactId>ultraviewpager</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<type>aar</type>
</dependency>
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ In order to achieve vertical scroll, through exchanging MotionEvent in onInterce

#### Usage

Please find the latest version(1.0.3 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories.
Please find the latest version(1.0.4 so far) in maven repository. The newest version has been upload to jcenter and MavenCantral, make sure you have added at least one of these repositories.

Using Gradle:

```
//gradle
compile ('com.alibaba.android:ultraviewpager:1.0.3@aar') {
compile ('com.alibaba.android:ultraviewpager:1.0.4@aar') {
transitive = true
}
```
Expand All @@ -48,7 +48,7 @@ or grab via Maven:
<dependency>
<groupId>com.alibaba.android</groupId>
<artifactId>ultraviewpager</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<type>aar</type>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
GROUP=com.alibaba.android
ARTIFACT=ultraviewpager
VERSION=1
VERSION_NAME=1.0.3
VERSION_NAME=1.0.4
PACKAGING_TYPE=aar
systemProp.compileSdkVersion=23
systemProp.targetSdkVersion=23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ interface IUltraViewPagerFeature {
*/
void setItemRatio(double ratio);

/**
* Set the gap between two pages in pixel
*
* @param pixel
*/
void setHGap(int pixel);

/**
* Set item margin
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ public void setRatio(float ratio) {
viewPager.setRatio(ratio);
}

@Override
public void setHGap(int pixel) {
int screenWidth = getContext().getResources().getDisplayMetrics().widthPixels;
viewPager.setMultiScreen((screenWidth - pixel) / (float) screenWidth);
viewPager.setPageMargin(pixel);
}

@Override
public void setMaxHeight(int height) {
maxHeight = height;
Expand Down

0 comments on commit c241c62

Please sign in to comment.