forked from wenmingvs/WeiBo
-
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
郭文明
committed
Sep 5, 2016
1 parent
5a9f0bd
commit b8803a7
Showing
5 changed files
with
146 additions
and
2 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
41 changes: 41 additions & 0 deletions
41
...nming/weiswift/ui/login/fragment/home/imagedetaillist/animation/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,41 @@ | ||
package com.wenming.weiswift.ui.login.fragment.home.imagedetaillist.animation; | ||
|
||
import android.support.v4.view.ViewPager; | ||
import android.view.View; | ||
|
||
public class DepthPageTransformer implements ViewPager.PageTransformer { | ||
private static final float MIN_SCALE = 0.75f; | ||
|
||
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); | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
.../weiswift/ui/login/fragment/home/imagedetaillist/animation/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,47 @@ | ||
package com.wenming.weiswift.ui.login.fragment.home.imagedetaillist.animation; | ||
|
||
import android.support.v4.view.ViewPager; | ||
import android.util.Log; | ||
import android.view.View; | ||
|
||
public class RotateDownPageTransformer implements ViewPager.PageTransformer { | ||
|
||
private static final float ROT_MAX = 20.0f; | ||
private float mRot; | ||
|
||
|
||
public void transformPage(View view, float position) { | ||
|
||
Log.e("TAG", view + " , " + position + ""); | ||
|
||
if (position < -1) { // [-Infinity,-1) | ||
// This page is way off-screen to the left. | ||
view.setRotation(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); | ||
view.setPivotX(view.getMeasuredWidth() * 0.5f); | ||
view.setPivotY(view.getMeasuredHeight()); | ||
view.setRotation(mRot); | ||
} else { | ||
|
||
mRot = (ROT_MAX * position); | ||
view.setPivotX(view.getMeasuredWidth() * 0.5f); | ||
view.setPivotY(view.getMeasuredHeight()); | ||
view.setRotation(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. | ||
view.setRotation(0); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...ing/weiswift/ui/login/fragment/home/imagedetaillist/animation/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,52 @@ | ||
package com.wenming.weiswift.ui.login.fragment.home.imagedetaillist.animation; | ||
|
||
import android.support.v4.view.ViewPager; | ||
import android.util.Log; | ||
import android.view.View; | ||
|
||
public class ZoomOutPageTransformer implements ViewPager.PageTransformer | ||
{ | ||
private static final float MIN_SCALE = 0.85f; | ||
private static final float MIN_ALPHA = 0.5f; | ||
|
||
public void transformPage(View view, float position) | ||
{ | ||
int pageWidth = view.getWidth(); | ||
int pageHeight = view.getHeight(); | ||
|
||
Log.e("TAG", view + " , " + position + ""); | ||
|
||
if (position < -1) | ||
{ // [-Infinity,-1) | ||
// This page is way off-screen to the left. | ||
view.setAlpha(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 | ||
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