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.
1 parent
99d831f
commit 0c438b8
Showing
13 changed files
with
131 additions
and
75 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
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/test/banner/GallyPageTransformer.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,34 @@ | ||
package com.test.banner; | ||
|
||
import android.support.v4.view.ViewPager; | ||
import android.view.View; | ||
|
||
/** | ||
* 自定义动画效果 | ||
* 调用 banner.setPageTransformer()方法设置 | ||
*/ | ||
|
||
public class GallyPageTransformer implements ViewPager.PageTransformer { | ||
private static final float min_scale = 0.85f; | ||
|
||
@Override | ||
public void transformPage(View page, float position) { | ||
float scaleFactor = Math.max(min_scale, 1 - Math.abs(position)); | ||
float rotate = 20 * Math.abs(position); | ||
if (position < -1) { | ||
|
||
} else if (position < 0) { | ||
page.setScaleX(scaleFactor); | ||
page.setScaleY(scaleFactor); | ||
page.setRotationY(rotate); | ||
} else if (position >= 0 && position < 1) { | ||
page.setScaleX(scaleFactor); | ||
page.setScaleY(scaleFactor); | ||
page.setRotationY(-rotate); | ||
} else if (position >= 1) { | ||
page.setScaleX(scaleFactor); | ||
page.setScaleY(scaleFactor); | ||
page.setRotationY(-rotate); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.