forked from youth5201314/banner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddd36d6
commit 86b4d2c
Showing
13 changed files
with
198 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
banner/src/main/java/com/youth/banner/transformer/DepthPageTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.youth.banner.transformer; | ||
|
||
import android.support.v4.view.ViewPager; | ||
import android.view.View; | ||
|
||
public class DepthPageTransformer implements ViewPager.PageTransformer { | ||
private static float MIN_SCALE = 0.75f; | ||
@Override | ||
public void transformPage(View view, float position) { | ||
int pageWidth = view.getWidth(); | ||
if (position < -1) { // [-Infinity,-1) | ||
// This page is way off-screen to the left. | ||
view.setAlpha(0); | ||
} else if (position <= 0) { // [-1,0] | ||
// Use the default slide transition when | ||
// moving to the left page | ||
view.setAlpha(1); | ||
view.setTranslationX(0); | ||
view.setScaleX(1); | ||
view.setScaleY(1); | ||
} else if (position <= 1) { // (0,1] | ||
// Fade the page out. | ||
view.setAlpha(1 - position); | ||
// Counteract the default slide transition | ||
view.setTranslationX(pageWidth * -position); | ||
// Scale the page down (between MIN_SCALE and 1) | ||
float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) | ||
* (1 - Math.abs(position)); | ||
view.setScaleX(scaleFactor); | ||
view.setScaleY(scaleFactor); | ||
} else { // (1,+Infinity] | ||
// This page is way off-screen to the right. | ||
view.setAlpha(0); | ||
|
||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
banner/src/main/java/com/youth/banner/transformer/RotateDownPageTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.youth.banner.transformer; | ||
|
||
import android.support.v4.view.ViewPager; | ||
import android.view.View; | ||
|
||
import com.nineoldandroids.view.ViewHelper; | ||
|
||
public class RotateDownPageTransformer implements ViewPager.PageTransformer { | ||
private static final float ROT_MAX = 20.0f; | ||
private float mRot; | ||
|
||
|
||
public void transformPage(View view, float position) { | ||
|
||
|
||
if (position < -1) { // [-Infinity,-1) | ||
// This page is way off-screen to the left. | ||
ViewHelper.setRotation(view, 0); | ||
|
||
} else if (position <= 1) // a页滑动至b页 ; a页从 0.0 ~ -1 ;b页从1 ~ 0.0 | ||
{ // [-1,1] | ||
// Modify the default slide transition to shrink the page as well | ||
if (position < 0) { | ||
|
||
mRot = (ROT_MAX * position); | ||
ViewHelper.setPivotX(view, view.getMeasuredWidth() * 0.5f); | ||
ViewHelper.setPivotY(view, view.getMeasuredHeight()); | ||
ViewHelper.setRotation(view, mRot); | ||
} else { | ||
|
||
mRot = (ROT_MAX * position); | ||
ViewHelper.setPivotX(view, view.getMeasuredWidth() * 0.5f); | ||
ViewHelper.setPivotY(view, view.getMeasuredHeight()); | ||
ViewHelper.setRotation(view, mRot); | ||
} | ||
|
||
// Scale the page down (between MIN_SCALE and 1) | ||
|
||
// Fade the page relative to its size. | ||
|
||
} else { // (1,+Infinity] | ||
// This page is way off-screen to the right. | ||
ViewHelper.setRotation(view, 0); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
banner/src/main/java/com/youth/banner/transformer/ZoomOutPageTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.youth.banner.transformer; | ||
|
||
import android.support.v4.view.ViewPager; | ||
import android.view.View; | ||
|
||
public class ZoomOutPageTransformer implements ViewPager.PageTransformer { | ||
private static float MIN_SCALE = 0.85f; | ||
|
||
private static float MIN_ALPHA = 0.5f; | ||
|
||
@Override | ||
public void transformPage(View view, float position) { | ||
int pageWidth = view.getWidth(); | ||
int pageHeight = view.getHeight(); | ||
|
||
if (position < -1) { // [-Infinity,-1) | ||
// This page is way off-screen to the left. | ||
view.setAlpha(0); | ||
} else if (position <= 1) { // [-1,1] | ||
// Modify the default slide transition to | ||
// shrink the page as well | ||
float scaleFactor = Math.max(MIN_SCALE, 1 - Math.abs(position)); | ||
float vertMargin = pageHeight * (1 - scaleFactor) / 2; | ||
float horzMargin = pageWidth * (1 - scaleFactor) / 2; | ||
if (position < 0) { | ||
view.setTranslationX(horzMargin - vertMargin / 2); | ||
} else { | ||
view.setTranslationX(-horzMargin + vertMargin / 2); | ||
} | ||
// Scale the page down (between MIN_SCALE and 1) | ||
view.setScaleX(scaleFactor); | ||
view.setScaleY(scaleFactor); | ||
// Fade the page relative to its size. | ||
view.setAlpha(MIN_ALPHA + (scaleFactor - MIN_SCALE) | ||
/ (1 - MIN_SCALE) * (1 - MIN_ALPHA)); | ||
} else { // (1,+Infinity] | ||
// This page is way off-screen to the right. | ||
view.setAlpha(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Tue Apr 26 15:55:03 CST 2016 | ||
#Wed Aug 24 15:56:37 CST 2016 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip |