???????????????ViewHelper????????????????????????????????3.0??????????????????????????????????к????3.0????汾???????Ч?????????????????????ViewPager???????????????????ж??
????if (Build.VERSION.SDK_INT >= 11) //Android?汾?ж?
??????????????????????????汾????3.0???????????Ч??????????ò?????У??????????????????????????????д???????????setPageTransformer?????????汾?ж???????????
public void setPageTransformer(boolean reverseDrawingOrder?? ViewPager.PageTransformer transformer) {
//if (Build.VERSION.SDK_INT >= 11) //Android?汾?ж?
{
final boolean hasTransformer = transformer != null;
final boolean needsPopulate = hasTransformer != (mPageTransformer != null);
mPageTransformer = transformer;
setChildrenDrawingOrderEnabledCompat(hasTransformer);
if (hasTransformer) {
mDrawingOrder = reverseDrawingOrder ? DRAW_ORDER_REVERSE : DRAW_ORDER_FORWARD;
} else {
mDrawingOrder = DRAW_ORDER_DEFAULT;
}
if (needsPopulate) populate();
}
}
??????????????????????????????????????
????<com.example.android_viewpager.ViewPagerCompate
????android:id="@+id/viewPager"
????android:layout_width="match_parent"
????android:layout_height="match_parent">
????</com.example.android_viewpager.ViewPagerCompate>
????????MainActivity?????Щ?????
????mViewPager = (ViewPagerCompate) findViewById(R.id.viewPager);//?????????
??????????????????Ч????????3.0????汾???????????????о??????檔????????????????Ч????
public class RotateDownPagetransformer implements ViewPager.PageTransformer {
private static final float MAX_ROTATE = 20F;
private static float ROTATE = 0F;
/*
* Ч????????
* ?????????????A>B
* A??position:0.0 >> -1.0
* B??position:1.0 >> 0.0
* (non-Javadoc)
* @see android.support.v4.view.ViewPager.PageTransformer#
* transformPage(android.view.View?? float)
*/
@Override
public void transformPage(View view?? float position) {
int pageWidth = view.getWidth();
if (position < -1) { // [-Infinity??-1)
ViewHelper.setAlpha(view?? 0);//?????????
} else if (position <= 0) { // A?position:0.0 >> 1.0
//??????????
ROTATE = MAX_ROTATE * position;
//???????????
ViewHelper.setPivotX(view?? pageWidth/2);
ViewHelper.setPivotY(view?? view.getMeasuredHeight());
//?????????
ViewHelper.setRotation(view?? ROTATE);
} else if (position <= 1) { // B?position:1.0 >> 0.0
//??????????
ROTATE = MAX_ROTATE * position;
//???????????
ViewHelper.setPivotX(view?? pageWidth/2);
ViewHelper.setPivotY(view?? view.getMeasuredHeight());
//?????????
ViewHelper.setRotation(view?? ROTATE);
} else { // (1??+Infinity]
ViewHelper.setAlpha(view?? 0);
}
}
}
????????????????????ε??л?Ч???????????ViewPager???л????????????????????????????????????????????????